SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Insert into - table back up need help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Movva
Starting Member

15 Posts

Posted - 04/01/2013 :  15:37:57  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
6062 Posts

Posted - 04/01/2013 :  15:48:06  Show Profile  Reply with Quote
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

Edited by - TG on 04/01/2013 15:50:25
Go to Top of Page

Movva
Starting Member

15 Posts

Posted - 04/01/2013 :  15:54:25  Show Profile  Reply with Quote
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 - 04/01/2013 :  15:56:41  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
6062 Posts

Posted - 04/01/2013 :  16:54:17  Show Profile  Reply with Quote
>>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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000