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 |
|
JacobPressures
Posting Yak Master
112 Posts |
Posted - 2009-04-03 : 11:33:04
|
| Supposed i have a list of IDs, names and sections in a table.NameID Name Section1 Sue 242 Robert 243 Bruce 244 Mike 255 Sam 256 Pam 25Now I want to take all the names where section is 25 and re-add them to the same table with a different section number. The result will be like this:NameID Name Section1 Sue 242 Robert 243 Bruce 244 Mike 255 Sam 256 Pam 257 Mike 308 Sam 309 Pam 30I know I can try something like the following:INSERT INTO tblName (Name, Section)Select * From tblNameWhere Section = 25But what i really want to do is change the Section to 30 not re-enter the same section number.Thanks very much! |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-04-03 : 11:34:35
|
| instead of select "*" use an explicit column list and replace the [section] with a constant or expression.Be One with the OptimizerTG |
 |
|
|
JacobPressures
Posting Yak Master
112 Posts |
Posted - 2009-04-03 : 11:48:23
|
| Thanks for the very quick reply!!! I understood the first part. I realize the error there.But the second part I'm not sure of. This is the best I can deduce. I actually think this will work. I'll give it a try. INSERT INTO tblName (Name, Section)Select Name, 30From tblNameWhere Section = 25 |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-04-03 : 11:49:48
|
| that query looks good. |
 |
|
|
JacobPressures
Posting Yak Master
112 Posts |
Posted - 2009-04-03 : 16:27:51
|
| Thanks TG!!!! Worked perfectly! I'm Just Mesmerized at how fast you responded. Thanks! |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-04-03 : 16:30:59
|
The speed of my responses id proportional to the extent of my boredom here at work on a Friday afternoon. you're welcomeBe One with the OptimizerTG |
 |
|
|
|
|
|