Last post Jun 24, 2008 08:24 AM by klakieros
Jun 20, 2008 07:21 PM|klakieros|LINK
I need a sample query text to copy content of one table and update another table (in different database) with this data.
Jun 21, 2008 12:01 AM|mohamed.alsakaf|LINK
Hi Try this,
INSERT INTO DestinationDataBase.dbo.Store_Information (store_name, Sales, Date)
SELECT store_name, Sales, Date
Here I am mentioning the DestinationDataBase. Put the DataBase Name Where You want to insert the Data..
Hope this helps...
IF THIS POST HELPS YOU, CLICK MARK AS ANSWER
Jun 21, 2008 01:10 PM|klakieros|LINK
Could you please explain little bit what information should be included for example in:
I have entered db name like test.mdb but it didn't work. I am sure there must be information where the db is located...
Jun 23, 2008 12:56 AM|mohamed.alsakaf|LINK
Common klakieros Don't confuse. It's simple. U please mention in the DestinationDataBase as NorthWind and user as dbo and table as Store_Information
Finally this would be... NorthWind.dbo.Store_Information means U are accessing the table Store_Information which are located in NorthWind DataBase.
Don't include the DataBase Name with Extension .mdb.
Hope this helps,
If this post helps u, Click Mark as Answer
Jun 23, 2008 03:21 AM|Mikesdotnetting|LINK
The answers you have been given so far relate to SQL Server, and won't work with Access. You need to pass the file path into the SQL:
INSERT INTO table1 SELECT fields FROM [FullPathToDataBase2].[Table]
So, assuming that both databases are in your App_Data folder (which is where they should be) in MyProject, your code might look something like this:
string connect = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=|DataDirectory|db1.mdb";
OleDbConnection conn = new OleDbConnection(connect);
string sql = "INSERT INTO [Table1] SELECT * FROM [D:/Web Projects/MyProject/App_Data/db2].[Table1]";
OleDbCommand cmd = new OleDbCommand(sql, conn);
Jun 24, 2008 08:24 AM|klakieros|LINK
That helped Mike - thanks a lot again!