Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incrementer in a stored proc

Status
Not open for further replies.

Alibaba2003

Programmer
Mar 31, 2003
67
US
hi i would like to build a stored procedure that takes a number as an input. Say starting check number. For each row that the SP returns. I would like to increment the check number by 1.

Sample Iput: @StartingCheckNumber = 2345

Exec sp_Check_nums will produce

Payee CheckNumber Amount
----- ------------ -------
Jack Balance 2345 100.00
Morris Overdraft 2346 555.00
Nataly AllWidrawnInDeMall 2357 123.99

Thanks




It's Nice to Be Important But It's more Important to BE Nice
 
Try This:
Code:
declare @test bigint
select @test = 2300 --passed parameter

declare  @table table (rownum bigint identity(1,1) primary key 
						,payeeid varchar(50) 
					 )
insert @table
select payeeid
from   tableA
 
select  t.payee as Payee, t.rownum + @test as Checknumber, p.Amount as Amount
from	tableA p
inner	join @table t on t.payeeid = p.payeeid

With Great Power Comes Great Responsibility!!! [afro]

Michael
 
That works .. thanks

It's Nice to Be Important But It's more Important to BE Nice
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top