Home All Groups Group Topic Archive Search About

SQL SELECT INTO ... IN external_database - syntax error

Author
8 Jun 2006 6:17 PM
ryan_willow
I am trying to execute the following sql query on SQL Server 2000:

select * INTO "11111111_Poll 137_Archive" IN DB_91163_rwArchive from
"11111111_Poll 137"

And I receive the follwing error:
Incorrect syntax near the keyword 'IN'.

DB_91163_Archive is the name of an external database (on the same
server), 11111111_Poll 137 is the name of a table in the current
databse, and 11111111_Poll 137_Archive is the name of a table (to be
created) in the external db (double quotes used because of the space in
the table name). What am I doing wrong?

Thanks in advance.

Author
8 Jun 2006 6:28 PM
Mike C#
Are you looking for something like this:

SELECT *
INTO "11111111_Poll 137_Archive"
FROM DB_91163_rwArchive.dbo."11111111_Poll 137"

You need to specify a three-part name to specify a database different from
the one you are currently in.

<ryan_wil***@hotmail.com> wrote in message
Show quoteHide quote
news:1149790664.752303.234330@u72g2000cwu.googlegroups.com...
>I am trying to execute the following sql query on SQL Server 2000:
>
> select * INTO "11111111_Poll 137_Archive" IN DB_91163_rwArchive from
> "11111111_Poll 137"
>
> And I receive the follwing error:
> Incorrect syntax near the keyword 'IN'.
>
> DB_91163_Archive is the name of an external database (on the same
> server), 11111111_Poll 137 is the name of a table in the current
> databse, and 11111111_Poll 137_Archive is the name of a table (to be
> created) in the external db (double quotes used because of the space in
> the table name). What am I doing wrong?
>
> Thanks in advance.
>
Are all your drivers up to date? click for free checkup

Author
8 Jun 2006 6:42 PM
ryan_willow
Wow thanks for the ridiculously fast reply Mike, its exactly what I
needed.

Mike C# wrote:
Show quoteHide quote
> Are you looking for something like this:
>
> SELECT *
> INTO "11111111_Poll 137_Archive"
> FROM DB_91163_rwArchive.dbo."11111111_Poll 137"
>
> You need to specify a three-part name to specify a database different from
> the one you are currently in.

Bookmark and Share