Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Query Select into

Posted on 2008-09-30
3
Medium Priority
?
183 Views
Last Modified: 2012-05-05
Good Day

Experts:

Started the day off with a little challenge that I need help with.  I have data in Table "A"  database "Production".  I would like to do a Select * from A where ID = '5' then I want to insert the results
into database "Test" table "A".

Is this possible since they tables are in different db's?   If so, how can I achieve this?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 22606625
Yes, notice the .. (might need to be .owner_name. if appropriate)

INSERT INTO Test..A (Column1, Column2, Column3, ColumnN)
SELECT pa.Column1, pa.Column2, pa.Column3, pa.ColumnN
FROM Production..A pa
WHERE pa.ID = 5
0
 

Author Closing Comment

by:Jimbo99999
ID: 31501599
Thanks for the help.  I'll put that one in the back pocket for future use.
jimbo99999
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 22606912
Thanks for the grade.  Good luck with your project.  -Jim

Keep in mind though, using this approach creates a dependancy on Production..A FROM Test..A.
If you ever change the schema in Production..A, you'll have to go fish and find everything that touches it, which now will be T-SQL on another db.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question