Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I have a table named TABELA looks like thisCode seq Name Balance123 01 carlos 123,88123 02 maria 88,55Code and Seq are keys, i give a new key (ex. 888) and would like to duplicate the above rows changing only the keys and the table should be:Code seq Name Balance123 01 carlos 123,88123 02 maria 88,55888 01 carlos 123,88888 02 maria 88,55tksCarlos Lages
simondeutsch
Aged Yak Warrior
547 Posts
Posted - 2004-02-22 : 22:13:52
Create a table of keys and cross join it with the data, then insert it into TableA.
INSERT TableA(Code,seq,Name,balance) SELECT #Keys.Code,T.seq,T.Name,T.Balance FROm #Keys,TableA