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 2000 Forums
 Transact-SQL (2000)
 query loop

Author  Topic 

gt6974a
Starting Member

2 Posts

Posted - 2007-05-22 : 15:33:58
I have several rows that I want to reinsert into the same table but change 2 of the column's names.

I know there exists a way to do this by looping, I just don't know it. Thanks

i.e.

insert into tblThisTable
userid, username, column_a, column_b
values
userid = 000,
usename = 'newusername'
column_a = (select column_a from tblThisTablewhere userid = 111 and username = 'oldusername'
column_b = column_b = (select column_b from tblThisTablewhere userid = 111 and username = 'oldusername'

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-22 : 16:06:59
see: http://www.sqlteam.com/item.asp?ItemID=277

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

gt6974a
Starting Member

2 Posts

Posted - 2007-05-22 : 16:21:37
that did it, thanks
Go to Top of Page
   

- Advertisement -