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
 Transact-SQL (2000)
 Counter

Author  Topic 

majkinetor
Yak Posting Veteran

55 Posts

Posted - 2006-03-24 : 07:15:01
In what sql form can I do this:

DECLARE @cnt int
set @cnt = 0

select @cnt = @cnt + 1, Colon1, Colon2 ....
from tTable

I know how can I do I do it using temporary table and update, but I am wondering is there any way to do this in single sql statement, like the one above ?

www.r-moth.com

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2006-03-24 : 07:20:23
Have you considered using an identity column?

Look it up in Books Online.


Duane.
Go to Top of Page

majkinetor
Yak Posting Veteran

55 Posts

Posted - 2006-03-24 : 07:46:49
That is not what I have asked.
I asked is ther any way to create this "on the fly" not via temporary tables.



www.r-moth.com
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2006-03-24 : 07:50:59
quote:
Originally posted by majkinetor

That is not what I have asked.
I asked is ther any way to create this "on the fly" not via temporary tables.



www.r-moth.com


well in that case you can't
What you are trying to do is some kind of reporting function and should be handled by the reporting app.

Or......
You could use a temp table with an identity column (which is NOT necessarilly what I suggested earlier) - your base table could also have an identity column - That way you still get it back in one statement.


Duane.
Go to Top of Page

majkinetor
Yak Posting Veteran

55 Posts

Posted - 2006-03-24 : 08:16:14
You see, it wasn't that hard.

Thank you.


www.r-moth.com
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2006-03-24 : 08:22:03
You are correct it wasn't that hard.
I also don't find it too hard to be polite when I ask for help either.


Duane.
Go to Top of Page

majkinetor
Yak Posting Veteran

55 Posts

Posted - 2006-03-24 : 08:28:56
What exactly do you find to be impolite ?

"Thank you" part or something else ?

Dont get me wrong, if I have to explain whole day because everybody wants to post something, it is not my definition of help.

When I post here, I want people to answer my questions, since I put effort constructing non dubious, non questionable topics so to avoid wasting my and your time. It's just that, nothing more...

It was enought just to say "U can't do that.". Period.

I consider the best answer to be in pure mathematical form

www.r-moth.com
Go to Top of Page
   

- Advertisement -