I have a stored procedure that I want to make a copy of a row in a table, except to change the key field and a couple of others. Here is what I have so far:
Create Procedure procCreateAndCopy
@smpId as int
@smpNewId as int
As
Select *
Into #tmpSample
From Sample
Where smpId = @smpId
Update #tmpSample
Set smpId = @smpNewId,
Insert Into Sample
Select * From #tmpSample
It works fine unitl the Insert Into Sample. The error I get is:
Cannot insert a non-null value into a timestamp column. Use INSERT with a column list or with a default of NULL for the timestamp column.
I am hoping NOT to have to list all of the columns in the table due to both laziness on my part but also due to not wanting to have to modify the stored procedure if the table layout changes.
Thanks.
Create Procedure procCreateAndCopy
@smpId as int
@smpNewId as int
As
Select *
Into #tmpSample
From Sample
Where smpId = @smpId
Update #tmpSample
Set smpId = @smpNewId,
Insert Into Sample
Select * From #tmpSample
It works fine unitl the Insert Into Sample. The error I get is:
Cannot insert a non-null value into a timestamp column. Use INSERT with a column list or with a default of NULL for the timestamp column.
I am hoping NOT to have to list all of the columns in the table due to both laziness on my part but also due to not wanting to have to modify the stored procedure if the table layout changes.
Thanks.