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
 General SQL Server Forums
 New to SQL Server Programming
 SQL COPY AND PASTE

Author  Topic 

edb2012
Starting Member

19 Posts

Posted - 2012-05-10 : 15:39:28
Greetings,
I am trying to copy the table fields from one database into another without individually coping all 50 fields, their datatypes and nulls.

I tried both of these in query analyzer.

#1

CREATE TABLE dbo.FDL.MyAcct like dbo.DD1.MyAcct

and

#2

SELECT * INTO dbo.FDL.MyAcct from dbo.DD1.MyAcct where 0=1

None of these work. I get invalid object name errors. Can someone tell me what is the correct syntax for my request?

I greatly appreciate it ;-)

Ed

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-10 : 15:49:54
it should be

USE [FDL]

SELECT * INTO MyAcct from [DD1].dbo.MyAcct where 0=1


also they should be in same server

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

edb2012
Starting Member

19 Posts

Posted - 2012-05-10 : 16:07:32
WOW! That certainly did the job. Thank you so much ;-)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-10 : 16:09:05
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -