Thursday, March 8, 2012

a short question ?

how can i convert the varchar value to a column of data type int?

i am trying to do this


declare @.w varchar(50)
select @.w = col1 from myTable

select colname from mtable
where mtableID in (@.w)


but the mtableID is a int

and i always got

Syntax error converting the varchar value to a column of data type int.

thanks for everyone for helpingtry this


where mtableID in CAST(@.w AS int)

not sure if you want to swap your "in" for an "=" or not...

No comments:

Post a Comment