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
 Simple solution?

Author  Topic 

Topaz
Posting Yak Master

199 Posts

Posted - 2010-06-21 : 05:43:36
I'm sure that the answer to this problem would be fairly simple to a SQL master. So please don't laugh...

I have two SQL databses. In database1 I have a table that I want to copy into database2. Any ideas on how to go about this?

Many thanks...

JT

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-06-21 : 05:48:35
insert db2.table2(col list here)
SELECT (col list here)
from db1.table1



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-06-21 : 06:07:20
It'll be your comma after Bademail.

Also, if it is a different database, you need owner as well, so db2.Spammers -> db2.ShouldbeShot.Spammers
Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2010-06-21 : 06:08:55
Made changes but:

Msg 208, Level 16, State 1, Line 1
Invalid object name 'wce_site.Spammers'

insert Spammers.spamdb (uniqueid,
website,
expressemail,
salutation,
website1,
website2,
website3,
unsubscribe,
lastclick1,
lastclick2,
lastclick3,
lastclick4,
lastopen,
lastmailed,
Lastsentby,
LastTitle,
idstatus,
recordowner,
blank,
Bademail)

SELECT uniqueid,
website,
expressemail,
salutation,
website1,
website2,
website3,
unsubscribe,
lastclick1,
lastclick2,
lastclick3,
lastclick4,
lastopen,
lastmailed,
Lastsentby,
LastTitle,
idstatus,
recordowner,
blank,
Bademail

from wce_site.Spammers

????


JT
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-21 : 06:28:55
[databasename].[schemaname].[tablename]

maybe for example: wce_site.dbo.Spammers and (Spammers.dbo.spamdb or spamdb.dbo.Spammers)


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -