I am trying to create a stored procedure that will take a row with columns a,b,c,d where id = @id and insert a new row with the same values for a,b,c except d would be different.
In this case there are around 50 columns, though only the one column needs to be different.
Assuming
dis anINTand you want to insert, say,15instead of whatever is indbo.oldtable, then:More likely it is from a variable, so:
Sorry, but there is no shorthand to say “all the columns except d”… you need to list them out separately. If typing is the problem, there is an easy way to deal with that. Open Object Explorer, expand your server, database, tables, and the table in question, then drag the columns node onto the query window:
Now you’ll just have to delete the
dcolumn from that list.