i wan to print 1 to 100 in sql server with out using loops,tables and Union,

Posted by Johnseelan under ASP.NET on 2/16/2011 | Points: 10 | Views : 9420 | Status : [Member] | Replies : 5
hi
i wan to print 1 to 100 in sql server with out using loops,tables and Union,
please can you help me...




Responses

Posted by: PandianS on: 2/16/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi John

Yes. you can do that!
;WITH CTEs

AS
(
SELECT 1 [Sequence]
UNION ALL
SELECT [Sequence] + 1 FROM CTEs WHERE [Sequence] <100
)
SELECT * FROM CTEs
But, you have to use UNION ALL instead :)

Cheers
www.sqlserverbuddy.blogspot.com

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naimishforu on: 2/16/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Never kew dis one..!!

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/16/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Good one!!!

Thanks
Karthik
www.f5Debug.net

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/16/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Nice one Pandian..

Thanks and Regards
Madhu

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/16/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Pandian,

Can you brief on how this query works?

Thanks
Karthik
www.f5Debug.net

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response