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)
 Store Proc. - Code Posted - Looping help

Author  Topic 

abarsami
Yak Posting Veteran

68 Posts

Posted - 2001-06-13 : 17:46:34
This store procedure inserts one row only ... the last row into X.
I need it to loop through Table A and insert all the rows into X.
Can someone help.. or post the code with mine to make it loop.
Thanks

create Procedure dbo.usp_Ins_REB

AS

set nocount on
declare @mgi_name varchar(80)
declare @mgi_code varchar(20)
declare @hotel_code varchar(20)
declare @adj_day_d datetime
declare @day_reb_amt money
select
@hotel_code = hotel_code
,@adj_day_d = adj_day_d
,@mgi_name = mgi_name
,@day_reb_amt = day_reb_amt
From
TableA

if (@mgi_name = 'GROUP')
select @mgi_code = 'G'

if (@mgi_name = 'TRANSIENT')
select @mgi_code = 'T'

if (@mgi_name = 'OTHER')
select @mgi_code = 'O'

Insert Into X (
hotel_code
,mgi_code
,adj_day_d
,adj_day_adj_final_amt
)
Values (
@hotel_code
,@mgi_code
,@adj_day_d
,@day_reb_amt
)

   

- Advertisement -