View Single Post
  #2 (permalink)  
Old June 9th, 2003, 03:29 AM
pgtips pgtips is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

So you just want to copy a row but give the new row a new id? How about something like this:
CREATE PROC CopyRow
    @id as integer,
    @newid as integer OUTPUT
AS
    INSERT TableName
    SELECT (list all fields except the identity here) FROM TableName
    WHERE IdentityName = @id

    SET @newid = @@IDENTITY

I assume you know how to pass params in and retrieve output params, since you say you have written sprocs before...If not just ask.

hth
Phil
Reply With Quote