user380432
user380432

Reputation: 4779

SQL Set variable with single column in select field

I have a column along with many 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!

Upvotes: 0

Views: 2946

Answers (1)

Carlos
Carlos

Reputation: 2513

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

Upvotes: 3

Related Questions