Sunday, December 19, 2010

SQL Server SUBSTRING giving me incorrect results

I get incorrect result when i try to do a substring within a stored proc,but the same thing if i try it in a query window gives me proper results.

declare @FinalCol_List as varchar(100)
Set @FinalCol_List= '11,22,33,bb,'
print @FinalCol_List
IF LEN(@FinalCol_List) > 0
SET @FinalCol_List = SUBSTRING(@FinalCol_List, 1, LEN(@FinalCol_List) - 1)

print @FinalCol_List