Solved

Getting Count(*) into a varibale

Posted on 2013-12-05
2
255 Views
Last Modified: 2013-12-05
Experts,

here is my sample code and have tried multiple options and couldn't get it worked to assign the count(*)  to my variable so that I can use that value for later


Declare @@Total

SELECT @Total  = count(*) FROM (
SELECT  T1.ItemID
FROM MyDatabase..MyTable T1
INNER JOIN
INNER JOIN
INNER JOIN
...
WHERE
GROUP BY T1.ItemID
      HAVING  
)
 

Thanks in advance.
0
Comment
Question by:Tpaul_10
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 200 total points
ID: 39699439
Declare @Total int

SELECT @Total  = count(*) FROM (
SELECT  T1.ItemID
FROM MyDatabase..MyTable T1
INNER JOIN
INNER JOIN
INNER JOIN
...
WHERE
GROUP BY T1.ItemID
      HAVING  
)A
0
 

Author Closing Comment

by:Tpaul_10
ID: 39699458
Thank You Aneeshattingal, appreciate your quick help
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now