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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to "duplicate" a row

Author  Topic 

macsterling
Yak Posting Veteran

56 Posts

Posted - 2009-03-23 : 07:11:41
I need to make a copy of a row with 20 - 30 columns. Any way to do it quickly and efficiently?

Mac

ra.shinde
Posting Yak Master

103 Posts

Posted - 2009-03-23 : 07:22:28
insert into <table>
<select statement which will select the row you want to duplicate>

Rahul Shinde
Go to Top of Page

macsterling
Yak Posting Veteran

56 Posts

Posted - 2009-03-23 : 07:35:35
I am looking for a way to copy the data from the existing row without having to key for each column.

the ideal would be
insert <table>
"COPY" where xxxxxx
Go to Top of Page

ra.shinde
Posting Yak Master

103 Posts

Posted - 2009-03-23 : 07:42:20
you dont have to key each column.
insert <table>
SELECT * from <table> where xxxxxx



Rahul Shinde
Go to Top of Page

macsterling
Yak Posting Veteran

56 Posts

Posted - 2009-03-23 : 08:41:56
That is so simple, if I hadn't thought so much I would have just coded it! thanks
Go to Top of Page
   

- Advertisement -