>>ALTER PROCEDURE [dbo].[CreateSubFile] >> @TestSection nchar(1), >> @TestSub nchar(1) >> >>ASBEGIN >> declare @iError int, @iRowCnt int >> -- SET NOCOUNT ON added to prevent extra result sets from >> -- interfering with SELECT statements. >> SET NOCOUNT ON; >> select SubID = 0, Category, CorrectResp, Stem, RespA, RespB, RespC, RespD, OrigItmID >> into #SubFile from CATMaster >> where 1 = 0 >> >> if @TestSection = 'L' >> Insert into #Subfile select SubID = MasterID, Category, CorrectResp, Stem, >> RespA, RespB, RespC, RespD, OrigItmID >> from CATMaster >> where MasterID in (Select CatID from CATStats where subbank = @TestSub) >> and Category in ('40','41') >> else >> insert into #Subfile select SubID = MasterID, Category, CorrectResp, Stem, RespA, RespB, RespC, RespD, OrigItmID >> from CATMaster >> where MasterID in (Select CatID from CATStats where subbank = @TestSub) >> and Category >= '50' >> >> select @iError = @@error, @iRowCnt = @@rowcount >> >> if @iError > 0 >> begin >> raiserror('Error on Insert into Invoice - %d',16,1, @iError) >> --Set @MsgErr = 'Error on Insert into Mastere - %d' >> end >>END >>>