开发者

SQL Set variable with single column in select field

开发者 https://www.devze.com 2023-01-13 05:53 出处:网络
I have a column along with man开发者_Python百科y others that returns a int value. It is the same int value for every record in this column. If this value is 1 I need to set a variable = 1 if it is 0 i

I have a column along with man开发者_Python百科y others that returns a int value. It is the same int value for every record in this column. If this value is 1 I need to set a variable = 1 if it is 0 i want the variable to be 0. How do I go about doing this?

There can only be a 0 or 1 in that column. And again it is the same throughout the entire column each time the query is ran.

Thanks!


I'm not sure if I understood your problem correctly, but how about SET @Variable = (SELECT TOP 1 TheColumn FROM TheTable)?

0

精彩评论

暂无评论...
验证码 换一张
取 消