×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SELECT * INTO table IN db
4

SELECT * INTO table IN db

SELECT * INTO table IN db

(OP)
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?

RE: SELECT * INTO table IN db

This is the forum for SQL Server Programming questions:
forum183: Microsoft SQL Server: Programming

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.

RE: SELECT * INTO table IN db

(OP)
Oh .. So what is this forum for?
Thanks for the answer!

Tao Te Ching Discussions : Chapter 9 (includes links to previous chapters)
What is the nature of conflict?

RE: SELECT * INTO table IN db

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.

RE: SELECT * INTO table IN db

2
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

RE: SELECT * INTO table IN db

(OP)
I -knew- that bothered me. What is the proper ANSI SQL way of doing this?

Tao Te Ching Discussions : Chapter 9 (includes links to previous chapters)
What is the nature of conflict?

RE: SELECT * INTO table IN db

the proper way:

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

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

smile  

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close