• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 833
  • Last Modified:

select result as variable

I was wondering what the syntax would be to have a variable named @var that would be set as the result of a select Count(*) from table_name. Is there a way to have the select run, assign the count to the @var and then keep going?
0
arvanhalleorg
Asked:
arvanhalleorg
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
SELECT @var = Count(*) from table_name
0
 
Kinger247Commented:
DECLARE @Var as int
select @var = count(*) from table_name
SELECT @Var
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now