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
 SQL Server Administration (2005)
 How to import transfer file

Author  Topic 

ilee1
Starting Member

5 Posts

Posted - 2007-05-16 : 03:21:14
Hi there,

Since it's very urgent, can somebody help me on how to copy one column from one table and paste it into another table in the same database SQL server 2005.....

Thanks,
ilee1

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-16 : 03:28:00
By "column", do you mean colum data or column definition? If it column data, it's very simple:

Update d
set col = s.col
from SourceTbl s join DestTbl d on s.pk = d.pk


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

ilee1
Starting Member

5 Posts

Posted - 2007-05-16 : 03:55:33
Hi Harsh,

Thanks for the reply. I already tried your code but failed.
pk is primary key?? s.pk is different from d.pk.
One is number, one is unique identifier.
I just want to overwrite the column with the other. Thanks


quote:
Originally posted by harsh_athalye

By "column", do you mean colum data or column definition? If it column data, it's very simple:

Update d
set col = s.col
from SourceTbl s join DestTbl d on s.pk = d.pk


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-16 : 03:59:03
So there is no relation between these two tables? Then how can you overwrite a column in one table with column from another table?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

ilee1
Starting Member

5 Posts

Posted - 2007-05-16 : 04:08:16
OK, basically this column is the "company name" column which we don't want to repeat typing them again one by one.

To be frank this table is imported from MS Access table and now become new table in SQL server. And just want one column of it to be copied over to the existing table in SQL.
They have same rows of 250 but pk are different. How....ya....??
Go to Top of Page

ilee1
Starting Member

5 Posts

Posted - 2007-05-16 : 05:25:05
Anybody can help....., please...?
It's very frustrating.....Thanks
Go to Top of Page
   

- Advertisement -