Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 825
  • 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

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

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