Click here to Skip to main content
16,016,693 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
in storedprocedure how to print 1 to 100 numbers
Posted

SQL Server:

Do you really want to "PRINT" 100 numbers? Or do you want to return a result set?

-- Printing only.
create procedure print100
AS
begin
declare @seqno int;
set @seqno=0;
While (@seqno < 100)
begin
set @seqno = @seqno + 1;
print cast(@seqno as varchar(8));
end
end
go
 
Share this answer
 
You can't print anything in a stored proc. You can select a static sequence and return it if you want to. You should perhaps be more clear what you're hoping to do.

select 1,2,3,4,5,...100 will return those numbers. You may be able to do it in a shorter syntax, too.
 
Share this answer
 
Comments
fjdiewornncalwe 7-Jul-11 18:21pm    
In its simplest form, correct, so +5 and a counter for the silly univote.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900