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

前端 未结 8 1226
死守一世寂寞
死守一世寂寞 2020-12-01 09:59

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

8条回答
  •  感动是毒
    2020-12-01 10:43

    From: http://www.sql-server-helper.com/error-messages/msg-536.aspx

    To use function LEFT if not all data is in the form '1/12' you need this in the second line above:

    Set Col2 = LEFT(Col1, ISNULL(NULLIF(CHARINDEX('/', Col1) - 1, -1), LEN(Col1)))
    

提交回复
热议问题