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
 INSERT INTO

Author  Topic 

silas2
Yak Posting Veteran

65 Posts

Posted - 2005-08-19 : 10:50:24
In Access/MDB, with INSERT INTO, you have an "In 'Another.mdb'" clause which lets you insert into different dbs. Without resorting to linking tables to an Access db, can you get the same functionality in SQL Server? I know bcp lets you go to a flat file - is that the nearest?

Kristen
Test

22859 Posts

Posted - 2005-08-19 : 10:59:44
Like this?

INSERT INTO OtherDatabase.dbo.RemoteTable
SELECT *
FROM MyLocalTable

Kristen
Go to Top of Page

silas2
Yak Posting Veteran

65 Posts

Posted - 2005-08-19 : 11:27:12
That might do it.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-22 : 01:15:33
I think it is better to explicitely specify the columns than *

INSERT INTO OtherDatabase.dbo.RemoteTable(col1,col2,..colN)
SELECT col1,col2,..colN
FROM MyLocalTable


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-08-22 : 14:38:34
"better to explicitely specify the columns"

I took that as a given, but that's a bit of a wild assumption given that I don't know the people I'm replying to!

Thanks for pointing that out madhivanan

Kristen
Go to Top of Page
   

- Advertisement -