Showing posts with label stupid. Show all posts
Showing posts with label stupid. Show all posts

Monday, February 13, 2012

Copy rows across to another db

Hello all,

first of all please forgive me for asking what might turn out to be a very stupid question. I am new to SQL.

Here is my problem. I have to identical databases, one used for testing (db_test), the other for production (db_prod). What I want to do is to grab a row from a table in db_test and insert it into the relative table into db_prod.

Now, I know to use INSERT INTO, however I having problems specifiying which database to select from and which to insert to. I have tried specifying the full path ([db_test].[dbo].[Table1]) but it does not work. I can only get statements to work if is include the "USE [db_test]" line at the top, but I can't then access the other db.

Any suggestions?It is surprising that the cross database INSERT does not work. Perhaps you could post the query so I could see is there is an error?