Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT * INTO table IN db 4

Status
Not open for further replies.

Trevoke

Programmer
Jun 6, 2002
1,142
0
0
US
I am using SQL 2k.
I have two db (db1 and db2) on the server SERVER1.
Table1 is in db1.

I want to create a copy of table1 in table2 on db2..

use db1
select * into table2 in db2
from table1

gives me 'incorrect syntax near the keyword 'IN'.

The examples I found online say I have to do 'db2.db' or 'db2.mdb' ... Is that a reference to a file? I don't want to run something I don't understand..

Tao Te Ching Discussions : Chapter 9 (includes links to previous chapters)
What is the nature of conflict?
 
I am using SQL 2k
So, please, post in a SQL Server forum.
forum183

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This is the forum for SQL Server Programming questions:
forum183

However, the answer to your question is the following:
Code:
USE db1
SELECT * INTO db2.dbo.Table2
FROM Table1

Replace dbo with the name of another schema if needed.
 
This forum is for SQL coding questions when you are coding to one of the ANSI SQL standards. Basically, it means writing SQL which may be executed successfully on any database system which follows the standard.
 
So what is this forum for?
faq220-1073

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
the other reason you should post in the right forum is because ANSI SQL solutions aren't always appropriate

SELECT INTO, for example, is ~not~ ANSI SQL



r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
the proper way:

1. CREATE TABLE db2.dbo.Table2 ( ...

2. INSERT INTO db2.dbo.Table2 SELECT ... FROM db1.dbo.table1

:)

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top