473,320 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Count the number of rows in a UNION ALL statement

Hi,

Should be quite simple but can someone please tell me the best way to
count the number of rows in an UNION ALL statement.

I tried using @@ROWCOUNT but that doesn't seem to contain the correct
number.

Also, I assume that running the query again but just returning count(*)
instead of the data is horribly inefficient (plus the code is then
bloated.)?

Thanks,
Mark

Jan 8 '07 #1
1 2509
ma******@googlemail.com wrote:
Hi,

Should be quite simple but can someone please tell me the best way to
count the number of rows in an UNION ALL statement.

I tried using @@ROWCOUNT but that doesn't seem to contain the correct
number.
Why do you think so? Can you provide an example of a query with
incorrect @@ROWCOUNT value returned? What's the version of SQL Server?
--
Best regards,
Marcin Guzowski
http://guzowski.info
Jan 8 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: loRdK | last post by:
Hi, I have a database stored in MS SQL 2000 and an application written in VB5, which connects the database via JET/ODBC. I have a problem with the UNION statement.
5
by: Thomas Baxter | last post by:
Is it possible to have a conditional union statement in a stored proc? Here's an example on the northwind database. If says there's a syntax error near the UNION statement. Looks like it...
1
by: vic | last post by:
Hello, Dean Try this: select distinct c1, c2 into #tmp_1 from t1 select count(*) as cnt from #tmp_1 drop table #tmp_1 With best regards.
0
by: DataFreakFromUtah | last post by:
Hello! No question here, just a procedure for the archive. Search critera: count records imported count data imported count number of rows imported count number of records imported record import...
1
by: James | last post by:
Access 2003, trying to count the number of records that meet a criteria. According to Help: "In the Database window, click Queries under Objects, and then click New on the database window...
0
by: Ireneus Broncel | last post by:
I have a class which reads Groups and Users from ActiveDirectory. The Problem is, that i have about 10000 rows as product. When I am trying to read the "memberOf" Objects out of this field i get...
5
by: RC- | last post by:
Hi everyone, I have been searching and searching for an answer to this question using Google and what not; I have not been able to find a "clear cut" answer. OK, now the question: I have a...
5
by: isabelle | last post by:
hi, every body.. I have two program I couldn’t solve them So, can any body help me. please!! 1-Write a program that accepts a character and count number of occurrences in a file. The file...
11
by: Mack | last post by:
Hi all, I want to write a program to count number of bits set in a number. The condition is we should not loop through each bit to find whether its set or not. Thanks in advance, -Mukesh
1
by: jeddiki | last post by:
Hi, I want to get a subset from my table that includes rows that have an item (cb_id) with a unique ip address ( ip_adr). To be in the subset there should be at least two rows and if there are more...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.