Solved

Getting Count(*) into a varibale

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pivot Query Problem 9 52
configure service broker on all databases 2 98
Bubble user-defined Sql RAISERROR(...) to c# exception 14 225
How come this XML node is not read? 3 51
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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