SQLTeam.com | Weblogs | Forums

Read Txt file that is varchar and put in column of smallint


#1

My table variable is
DECLARE @XT smallint

My value of data is coming In from a string '12,1,45'
@VALUE is position 4 which has value of 1

When I set the @XT = @VALUE I get the conversion error cannot convert varchar to smallint

I read you have to use convert(smallint, @VALUE) but that didn't work nor cast

What are my best option to resolve?


#2

Can you post the code that is giving you the error? Not clear to me how you are extracting the value at position 4.