Solved

SQL Query Select into

Posted on 2008-09-30
3
176 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Delete from table 6 36
Custom auto number 6 51
How Can I fix my MouseHover Event? 14 26
.net VBA word safemode 1 23
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

13 Experts available now in Live!

Get 1:1 Help Now