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
 General SQL Server Forums
 New to SQL Server Programming
 CREATE DBO FROM OTHER

Author  Topic 

jfm
Posting Yak Master

145 Posts

Posted - 2012-05-14 : 09:28:33
Hi

Im trying to create a new_table from an existing_table in an other database2.

I did the query:

SELECT *
INTO database1.new_table
FROM database2.existing_table

And i woked, last week.

Today im trying to do the same and I have the following message:

msg 2760, level 16, state 1, line 1


Any ideas?

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-05-14 : 09:36:05
It means that one of the schemas database1 or database2 is not available in the current database

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-05-14 : 09:37:16
The syntax is not correct. You are missing a schema, or SQL Server treats "database1" and "database2" as the schema names.
And since the schema name is not correct, you get this error message.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

jfm
Posting Yak Master

145 Posts

Posted - 2012-05-14 : 09:39:56
So,

What im supposed to do? Because, as far as I know, I didn't make any changes in my database.

Whats the solution in this case?

Thanks
Go to Top of Page

jfm
Posting Yak Master

145 Posts

Posted - 2012-05-14 : 09:41:03
I know,

Its supposed to be my destination database the one SQL is not recognizing.

What can I do?

thanks
Go to Top of Page

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-05-14 : 10:23:06
[code]
use this

SELECT *
INTO database1..new_table
FROM database2..existing_table[/code]

Vijay is here to learn something from you guys.
Go to Top of Page

jfm
Posting Yak Master

145 Posts

Posted - 2012-05-14 : 11:00:55
It worked that way:

CREATE TABLE Destination_database..New_Table
FROM Existing_database.Info_Table


I dont understand, why using (..) in my destination file worked, and just using (.) in the existing one.

Thanks for your help!!





quote:
Originally posted by vijays3


use this

SELECT *
INTO database1..new_table
FROM database2..existing_table


Vijay is here to learn something from you guys.

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-05-14 : 11:27:28
.. Means that you are using the default schema, which in most cases are dbo.
What you reallt wrote was

CREATE TABLE Destination_database.dbo.New_Table
FROM Existing_database.dbo.Info_Table


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

jfm
Posting Yak Master

145 Posts

Posted - 2012-05-14 : 11:46:36
Perfect!!

Thank you very much


quote:
Originally posted by SwePeso

.. Means that you are using the default schema, which in most cases are dbo.
What you reallt wrote was

CREATE TABLE Destination_database.dbo.New_Table
FROM Existing_database.dbo.Info_Table


N 56°04'39.26"
E 12°55'05.63"


Go to Top of Page
   

- Advertisement -