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)
 From One Database To Another?

Author  Topic 

KingCarlos
Yak Posting Veteran

74 Posts

Posted - 2011-02-16 : 23:06:16
Hi there,

I am using this query to take data from one database to another

Insert into dbo.support.exoaddress (dbo.support.add1, dbo.support.add2, dbo.support.add3, dbo.support.add4, dbo.support.add5, dbo.support.add6)
select dbo.EXO_DEMO.dr_accs.address1,
dbo.EXO_DEMO.dr_accs.address2,
dbo.EXO_DEMO.dr_accs.address3,
dbo.EXO_DEMO.dr_accs.address4,
dbo.EXO_DEMO.dr_accs.name,
dbo.EXO_DEMO.dr_accs.accno from dbo.EXO_DEMO.dr_accs


but I get the following error

Msg 208, Level 16, State 1, Line 1
Invalid object name 'dbo.EXO_DEMO.dr_accs'.

How do I use a SQL script to get data from one database and copy into another database table?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-02-16 : 23:11:24
the 3 part name reference should be
[database].[schema].[table]

you have it the wrong way


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

KingCarlos
Yak Posting Veteran

74 Posts

Posted - 2011-02-16 : 23:23:23
Sorry there, I do not understand?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-02-16 : 23:35:55
change dbo.EXO_DEMO to EXO_DEMO.dbo



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

KingCarlos
Yak Posting Veteran

74 Posts

Posted - 2011-02-16 : 23:43:13
Insert into exoaddress (add1, add2, add3, add4, add5, add6)
select address1,
address2,
address3,
address4, ACCNO, NAME from EXO_DEMO.dbo.dr_accs

Cheers !!!

As you can see from my posts I am quite new to this!!!
Go to Top of Page
   

- Advertisement -