Im creating a procedure that simply creates a copy of a row but changes some values.
In the newly created record (which is a copy of an existing record) I need one of the fields to be a string representation of the recordID (an auto-generated IDENTITY column) of the newly created record.
CREATE PROC sp @RecordID int
AS
BEGIN
INSERT INTO TheTable([RecordName], ...)
SELECT CAST(@RecordID as nvarchar(500)), ...
FROM TheTable
WHERE [RecordID] = @RecordID
END
my code is wrong because it sets the RecordName to the RecordID of the record being copied FROM. I need the RecordName to be the same as the RecordID of the record being created.
Thanks for the help