create PROCEDURE [dbo].[sp] @Id1 int ,@BBId int ,@Text nvarchar(100) ='' AS Begin Begin TRY Begin transaction declare @Id int INSERT INTO table1 select @Text where @Text <> '' SET @Id = SCOPE_IDENTITY() INSERT INTO table2 (Id1, @Id) select @Id1,@Id from table3 where table3.BBId = @BBId AND table3.Flag= 0 and table3.Id1 = @Id1 UPDATE table3 SET Flag= 1 WHERE table3.BBId = @BBID AND table3.Id1 = @Id1 COMMIT TRANSACTION END TRY BEGIN CATCH ROLLBACK; throw END CATCH END Return 0
INSERT INTO table2 (Id1, @Id) select @Id1,@Id from table3 where table3.BBId = @BBId AND table3.Flag= 0 and table3.Id1 = @Id1
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)