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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Creating Duplicate rows for each row

Author  Topic 

Gigi
Starting Member

23 Posts

Posted - 2009-05-04 : 12:23:06
I have a table with 7 Columns and I want to create a duplicate row for each row. I can create the duplicate rows but there is some manupilation that I need to do to the duplicate record when creating them . The changes for the duplicated column will be
Col1 should be changed to text 'XYZ'
Col2 = Col3 from original row
Col3 = Col2 from original row
Col5 = Col5 from original row + 1

thank you in advance

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-05-04 : 12:41:51
INSERT INTO yourTable(Col1,Col2,Col3,Col5)
SELECT 'XYZ',Cols3,Col2,Col5 + 1
FROM yourTable

Jim
Go to Top of Page

Gigi
Starting Member

23 Posts

Posted - 2009-05-04 : 12:58:16
thank you...worked perfectly
Go to Top of Page
   

- Advertisement -