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)
 Insert Into Issue

Author  Topic 

rohan_iiitc
Starting Member

11 Posts

Posted - 2010-05-07 : 13:11:43
Friends

I am trying to make a insert querry for a table from one server to other table only for few columns, but i am getting error.

1) I want to put only selected column -- not working--
Insert into ABC.dbo.TBL_Customer (Col1,Col2,Col3,Col4)
Select Col1,Col2,Col3,Col4 from XYZ.dbo.TBL_Customer;

Is this the correct way.?

Insert into ABC.dbo.TBL_Customer
Select Col1,Col2,Col3,Col4 from XYZ.dbo.TBL_Customer;
Is working fine.

PLease help.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-07 : 13:39:48
Please post the error.

Your first method should work according to the limited information you have posted.

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

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-07 : 14:43:02
is any of col1,2,.. in ABC.dbo.TBL_Customer an identity field?

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

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-07 : 16:02:23
I wouldn't think the second method would work if any of those are an identity field.

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

Subscribe to my blog
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-05-07 : 16:58:12
Yes.The only thing I could think of was, if the columns Col1,Col2,Col3,Col4 were named differently in ABC.dbo.TBL_Customer

EDIT : possibly because of COLLATION differences between the two databases.
Go to Top of Page
   

- Advertisement -