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 |
|
nmarks
Yak Posting Veteran
53 Posts |
Posted - 2007-10-10 : 05:33:15
|
| How can I copy a column of data from table into another.One table is full of data, the other is entirely empty and both tables have identical structures.How can this be done quickly?Answers much appreciated. |
|
|
nmarks
Yak Posting Veteran
53 Posts |
Posted - 2007-10-10 : 05:39:04
|
| Fixed it. Thanks for reading though. |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-10-10 : 05:39:16
|
| [code]Insert into Dest_Table(Col1, col2, col3...)Select Col1, col2, col3...from Source_Table[/code]Note: Assuming both tables belong to same database.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-10 : 05:39:48
|
You mean UPDATE?Column X in TableB is empty (all values are NULL) and you have correct values in TableA?UPDATE bSET b.ColX = a.Col1FROM TableB AS bINNER JOIN TableA AS a ON a.PK = b.PK E 12°55'05.25"N 56°04'39.16" |
 |
|
|
QuachNguyen
Starting Member
15 Posts |
Posted - 2007-10-10 : 13:03:12
|
quote: Originally posted by harsh_athalye
Insert into Dest_Table(Col1, col2, col3...)Select Col1, col2, col3...from Source_Table Note: Assuming both tables belong to same database.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
Hi harsh_athalyeYour statement is work fine , It's new for me , but when I try to insert with identity column , I got the duplicate record message .And cannot insert to destination table .How can I do this with table that having identity column ? Thanks in advance .Sorry for poor english . |
 |
|
|
cognos79
Posting Yak Master
241 Posts |
Posted - 2007-10-10 : 13:54:32
|
| dont include the indentify column in the insert statement. |
 |
|
|
|
|
|