I use MS SQL in combination with SSIS where I need to copy and paste rows of a table (same table for source and destination) for a given DocumentID while also incrementing the "subversion" column.
Example:
DocumentID=123 | Location=a | Version=2 |Subversion=4
DocumentID=123 | Location=b | Version=2 |Subversion=4
DocumentID=123 | Location=c | Version=2 |Subversion=4
after copy:
DocumentID=123 | Location=a | Version=2 |Subversion=5
DocumentID=123 | Location=b | Version=2 |Subversion=5
DocumentID=123 | Location=c | Version=2 |Subversion=5
Within SSIS I already increment the max(Subversion) (from 4 to 5 in the example). What I need is a select/insert statement to copy the data.
Since this table has around 150 columns I was hoping for a way without listing all columns but I couldn't find any information if that is even possible.
I've tried Insert into in combination with Select but it always ended in errors (aggregate issues).
Insert Into MyTable (AllMyColumns)
select (AllmyColumns)
from MyTable
where DocumentID =123 AND ...
How do I need to build this statement?
thanks for your help.