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.
| Author |
Topic |
|
rtutus
Aged Yak Warrior
522 Posts |
Posted - 2006-09-01 : 11:07:57
|
| HiI have a table with a user column and other columns. User column id the primary key.I want to create a copy of the record where the user="user1" and insert that copy in the same table in a new created record. But I want the new record to have a value of "user2" in the user column instead of "user1" since it's a primary keyThanks. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-09-01 : 11:10:55
|
| insert tbl (User, co1, col2, col3, ...)select 'User2', co1, col2, col3, ...from tblwhere User = 'User1'==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
rtutus
Aged Yak Warrior
522 Posts |
Posted - 2006-09-01 : 11:34:18
|
| Thank you.I thought there was a way of doing that without going through the headache of specifying the name of all my columns (I have many columns)Thank you |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-09-01 : 11:36:37
|
| select name + ' ,' from syscolumns where id = object_id('mytable') order by colid==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
rtutus
Aged Yak Warrior
522 Posts |
Posted - 2006-09-01 : 13:17:55
|
| Can you explain a bit more this last suggestion. And how do i get all the columns exept "user"Thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-09-02 : 10:06:34
|
| In that query add and name<>'User'MadhivananFailing to plan is Planning to fail |
 |
|
|
rtutus
Aged Yak Warrior
522 Posts |
Posted - 2006-09-09 : 07:42:19
|
| Thanks |
 |
|
|
|
|
|