Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Creating temp table in a different database
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

n4nature
Starting Member

7 Posts

Posted - 10/03/2012 :  16:45:28  Show Profile  Reply with Quote
I am trying to extract a part of data into a temp table on a different database on a separate SQL server. Here's the query for that:


SELECT [DB1].[dbo].T1 .Col1, [DB1].[dbo].T2 .Col1, [DB1].[dbo].T1 .Col2, [DB1].[dbo].T2.Col2
INTO [DB2].dbo.DB2
FROM [DB1].[dbo].T1 


It's not recognizing DB2 here. When I run this query under SQL Server Management Studio, it gives an error:

Database 'DB2' does not exist.

If I comment out the line2 in above query, it compiles and works fine.

Any idea on how to fix this problem?

chadmat
The Chadinator

USA
1974 Posts

Posted - 10/03/2012 :  16:52:00  Show Profile  Visit chadmat's Homepage  Reply with Quote
You need to have a linked server to the other server. How would SQL know what server you are talking about?

-Chad
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 10/03/2012 :  17:28:33  Show Profile  Reply with Quote
see this to understand what all you need to do to add a linked server

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=164892

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

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.13 seconds. Powered By: Snitz Forums 2000