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 2008 Forums
 Transact-SQL (2008)
 how to copy particular data to other,,,

Author  Topic 

asifbhura
Posting Yak Master

165 Posts

Posted - 2011-06-10 : 15:29:30
Hello

I have two table, both table have customerName Field

I want to copy customerName from one table to another table

Regards

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-10 : 15:40:42
By "copy", do you mean insert or update?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

asifbhura
Posting Yak Master

165 Posts

Posted - 2011-06-10 : 15:46:36
I want to insert

but for knowledge i want to update statement also
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-10 : 15:51:50
INSERT INTO Table2 (...)
SELECT ...
FROM Table1

UPDATE t2
SET col1 = t1.col1
FROM Table2 t2
JOIN Table1 t1
ON t2.someCol = t1.someCol

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

asifbhura
Posting Yak Master

165 Posts

Posted - 2011-06-12 : 04:00:38
Hello

Update is not working properly,

in the original tableis having different data and after updating it is different

for Example

in original table on 1032 id number is like "HU Project"

and after updating it is taking another data..

i want to update table data with exact id to ID

is there any other query....

in table some id is having null also..

Regards,
ASIF
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-06-12 : 05:09:54
please show some sample data from tables and then explain what you're expecting. its quite difficult for someone to guess without seeing what exactly you're trying to achieve

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-12 : 22:10:54
Show us the query you tried and sample data like visakh mentioned.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -