![sql server gui copy column value to new row sql server gui copy column value to new row](https://heelpbook.altervista.org/wp-content/uploads/2018/10/sqlcsv2.png)
I need a generic stored proc that clones a specified row in an arbitrary table. if you are not going to follow the rules, all bets are off.If you mistyped and you meant insert someothert select * from t, then: alter table t drop constraint alter table t drop column idalter table t add constraint pk primary key ()insert someothert select * from t where naturalkey = White I take it you don't have a primary key, other wise you couldn't insert t select * from t.
![sql server gui copy column value to new row sql server gui copy column value to new row](https://res.cloudinary.com/dmsxwwfb5/image/upload/v1584365986/preview-data-sql-server-csv-import.png)
The only thing that comes to mind is to programatically perform that task using a stored procedure. Why can't you explicitly list the fields? that is really a best practice (as Tara has pointed out).To answer your question though, there is no way to have an exclude like you suggested.
![sql server gui copy column value to new row sql server gui copy column value to new row](https://i.stack.imgur.com/L7aei.png)
Just don't use *.INSERT INTO Table1 (Column2, Column3, Colum4)SELECT Col2, Col3, Col4FROM Table2WHERE Col1 = shouldn't be used in production code anyway, so start explicitly selecting the columns.Tara
#Sql server gui copy column value to new row how to
Any ideas on how to accomplish something like this? (Explicit field list is not an option.)Thanks in advance. Too bad T-SQL has no "except" clause to exclude fields, because it would be nice to just say "*-id". All ForumsĪny clever ways to duplicate an entire row of a generic table except the identity column (obviously can't be duped since it will auto-inc)?insert t select * from t where an error because it also tries to update the id col. We've got lots of great SQL ServerĮxperts to answer whatever question you can come up with.