Solved

SQL Query Select into

Posted on 2008-09-30
3
177 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
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 …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

947 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

21 Experts available now in Live!

Get 1:1 Help Now