Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Adding information to the beginning of a select statement

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-05 : 09:54:26
Travis writes "Hi,

Great site and good info. I have learned a lot. I did some searching and I haven't found an answer to this question...

I am returning a record set of search results to my web site. I want to send only one SELECT statement. In the SELECT statement I want to add information about the total number of records that I am sending, so that I can show the user how many results there are for his search. For another purpose, I also want to send a CDV string that will hold a list of the ID's that were selected. I would like these two values to be sent at the beginning of the SELECT statement.

An easy solution is of course to use something like this...

------------------
select t.Column1, t.Column2, @RecordCount, @CDVString
from Table1 as t, #TempTable as temp
where t.ID = temp.ID and temp.Num > @StartRecord and
temp.Num <= @StartRecord + @NumRecords
------------------

@RecordCount and @CDVString have been previously calculated.

The problem with this is that I am sending @RecordCount and @CDVString in every row of my SELECT statement. What I would like to do is send the information only once, at the beginning.

(Windows NT 4.0, SQL 2000)

Regards,

Travis"
   

- Advertisement -