How to split a string after specific character in SQL Server and update this value to specific column

SHEKHAR SHETE picture SHEKHAR SHETE · Feb 13, 2012 · Viewed 246k times · Source

I have table with data 1/1 to 1/20 in one column. I want the value 1 to 20 i.e value after '/'(front slash) is updated into other column in same table in SQL Server.

Example:

Column has value 1/1,1/2,1/3...1/20
new Column value 1,2,3,..20

i.e I want to update this new column

Thanks in advance...!

Answer

Lamak picture Lamak · Feb 13, 2012

Try this:

UPDATE YourTable
SET Col2 = RIGHT(Col1,LEN(Col1)-CHARINDEX('/',Col1))