Solved

SQL Query Select into

Posted on 2008-09-30
3
178 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
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 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 65

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now