Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Remove Last N Characters From Column

Posted on September 9, 2015 By David Kittell

Recently in a project to list all the plugins in a WordPress site with their versions I had accidently added .0 on to various rows in error.

This script was very helpful to correct this error

SELECT [id],
	[siteid],
	[pluginid],
	[versioninstalled],
	LEFT([versioninstalled], LEN([versioninstalled]) - 2),
	[Activated]
FROM [Documentation].[dbo].[tblWP_SiteToPlugin]
WHERE RIGHT([versioninstalled], 2) = '.0'
UPDATE [Documentation].[dbo].[tblWP_SiteToPlugin]
SET [versioninstalled] = LEFT([versioninstalled], LEN([versioninstalled]) - 2)
WHERE RIGHT([versioninstalled], 2) = '.0'

Reference: http://stackoverflow.com/questions/10470471/delete-last-n-characters-from-field-in-a-sql-server-database

All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code MSSQL SQL

Post navigation

Previous post
Next post

Related Posts

Mac OSX Terminal – Turn off system sleep

Posted on April 4, 2016April 4, 2016

If you use a Mac whether true server or a Mac Mini for a server this script below is very helpful to prevent the Mac from falling asleep and preventing the machine from being a server. # Disable Computer Sleep sudo systemsetup -setcomputersleep Off sudo systemsetup -getcomputersleep # Disable Computer…

Read More

Read Text File Line By Line

Posted on September 18, 2013October 26, 2015

Public Class ReadFromFile Shared Sub Main() Dim sFileName As String Dim srFileReader As System.IO.StreamReader Dim sInputLine As String sFileName = "test.txt" srFileReader = System.IO.File.OpenText(sFileName) sInputLine = srFileReader.ReadLine() Do Until sInputLine is Nothing System.Console.WriteLine(sInputLine) sInputLine = srFileReader.ReadLine() Loop End Sub End Class Originally Posted on September 18, 2013Last Updated on October…

Read More

BASH – Find all files with tab in the text

Posted on October 19, 2021August 17, 2024

grep -rnw . -e ‘\t’ // -r or -R is recursive, // -n is line number, and // -w stands for match the whole word. // -l (lower-case L) can be added to just give the file name of matching files. // -e is the pattern used during the search…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
©2025 David Kittell | WordPress Theme by SuperbThemes