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
 Transact-SQL (2005)
 How to create the table in another server?

Author  Topic 

shah_tech02
Starting Member

2 Posts

Posted - 2008-07-16 : 05:24:59
Hi All,

I need to create the SQL table in a different server using given SQL query.

I'm using the following statements but its giving error:

Select * into X.Y.dbo.table1
from select * from table2 aa

Error is as follows:
The object name 'X.Y.dbo.' contains more than the maximum number of prefixes. The maximum is 2.

From a different server I'm trying to create the table in server X, database Y.

Any ideas?

Thanks in advance

Shahtech

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-07-16 : 05:47:10
Hello,
it looks like you have not created a linked server.

Select *
into [myLinkedServer].[myDatabase].dbo.table1
from table2

Greetings
Webfred

There are 10 types of people in the world: Those who understand binary, and those who don't...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-16 : 06:36:47
or use OPENROWSET
Go to Top of Page

shah_tech02
Starting Member

2 Posts

Posted - 2008-07-16 : 06:58:23
created linked server, but still not working any more ideas?

Shahtech
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-07-16 : 10:01:45
can you explain please - still not working is not very helpful.

Greetings
Webfred

There are 10 types of people in the world: Those who understand binary, and those who don't...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-16 : 10:06:34
something like


SELECT a.* INTO Y.dbo.table1
FROM OPENROWSET('SQLNCLI', 'Server=yourotherservername;Trusted_Connection=yes;',
'SELECT*
FROM YourTable') AS a;
Go to Top of Page
   

- Advertisement -