Solved

Getting Count(*) into a varibale

Posted on 2013-12-05
2
261 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to PARSE a text field that is delimited by '~' character? 3 60
Change variables in SQL table 6 87
CROSS APPLY 4 51
SQL query with cast 38 42
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 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