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 2012 Forums
 Transact-SQL (2012)
 Insert into - table back up need help

Author  Topic 

Movva
Starting Member

15 Posts

Posted - 2013-04-01 : 15:37:57
Hi there,

I am trying to back up a table to another Common db. Here is the sql but for some reason it says that 'Incorrect syntax near IN'. I am using SQL Server 2012.

select *
INTO TableB IN 'Common.mdb'
from TableA

Thanks,

Dev

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-04-01 : 15:48:06
In sql server if you want to refer to a table in a database other than the database your code is executing then use dot notation to qualify the table (<database>.<schema>.<table>). ie:

use myDatabase

select *
INTO common.dbo.TableB
from TableA


Be One with the Optimizer
TG
Go to Top of Page

Movva
Starting Member

15 Posts

Posted - 2013-04-01 : 15:54:25
Figured this out.. the below works fine and I see it create a table in Common DB on the same server.

select *
INTO Common.dbo.TableB
from TableA
Go to Top of Page

Movva
Starting Member

15 Posts

Posted - 2013-04-01 : 15:56:41
Thanks Thanks for the reply TG. But in www3schools the syntax is a bit different

http://www.w3schools.com/sql/sql_select_into.asp

when do we use IN keyword as explained in the above link.

Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-04-01 : 16:54:17
>>when do we use IN keyword as explained in the above link.

That link is not specific to MS SQL Server and that usage will not work in sql server. So I would have to say, "never" .

For online help with ms sql server I strongly suggest you use Books Online

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -