Solved

select result as variable

Posted on 2006-11-23
2
807 Views
Last Modified: 2012-06-21
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
Comment
Question by:arvanhalleorg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 18004154
SELECT @var = Count(*) from table_name
0
 
LVL 10

Expert Comment

by:Kinger247
ID: 18004162
DECLARE @Var as int
select @var = count(*) from table_name
SELECT @Var
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question