How to check if my string contains leading letters? In C #, it's simple, but I do it in SQL. Is there any way to check this? If so, how to remove it?
EX: @MyString = 'A1234'
Updated line = '1234'
Using:
UPDATE YOUR_TABLE SET your_column = SUBSTRING(your_column, 2, DATALENGTH(your_column)) WHERE your_column LIKE '[A-Za-z]%'
For one leading letter, you can:
IF NOT ISNUMERIC(SUBSTRING(@MyString, 1, 1)) SET @MyString = SUBSTRING(@MyString, 2, LEN(@MyString))
You can repeat this until there are more letters.
SUBSTRING IF...
substring(@MyString,1,1) = 'A'
declare @val varchar(10) set @val = substring(@MyString,1,1)