View Single Post
  #8 (permalink)  
Old June 9th, 2003, 07:07 PM
David Cameron David Cameron is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: Sydney, NSW, Australia.
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

CREATE PROCEDURE MyProc
@Val1 Int, @Val2 Int, -- new rows
@OldID Int, -- ID for the old row
@newID Int OUTPUT
AS

SET NOCOUNT ON

INSERT INTO SomeTable
(Col1, Col2, Col3, Col4)
SELECT Col1, Col2, @Val1, @Val2
FROM SomeTable
WHERE SomeID = @OldID

SET @newID = scope_identity()

regards
David Cameron
Reply With Quote