Solved

Need help finishing view/query for SQL backend

Posted on 2007-04-10
2
164 Views
Last Modified: 2010-03-20
I am working on a sales database that is needs to be linked into a seperate database on the same server to pull some information. Both are SQL.  I have partially created the query i need in a view on the sales db side. But what i need to do now is finish the query so it populates the sales side with the needed info.  Or atleast gives me the view to where i can display it (the frontend is access 2003). I have a blank field that has contractID on the sales side.  I have a populated field with the contractID in the other database. I also have OPPID that acts as the key on both sides.  Can someone help me finish this query

SELECT     TimeMatters6.tm6user.matter.mat1_04_09, dbo.Job.OpportunityID, TimeMatters6.tm6user.matter.mat_no
FROM         TimeMatters6.tm6user.matter INNER JOIN
                      dbo.Job ON TimeMatters6.tm6user.matter.mat1_04_09 = dbo.Job.OpportunityID

I need to take the results and be able to view them in the sales database. I'm very new to sql so please be as literal as possible!!
0
Comment
Question by:riuser
[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
2 Comments
 
LVL 10

Accepted Solution

by:
ksaul earned 500 total points
ID: 18884455
Can you provide a list of all of the fields from each table that you want in the view?
Or, do you want one update statement to update ContractID? Also not sure about the fields your using to join - in your query you are joining matter to OpportunityID, but then you said OPPID acts as the key on both sides.

When using long table names it helps to use a short alias.  Here is an example of a cross-db view:

CREATE View YourViewName
AS

SELECT a.Field1, a.Field2, b.Field1, b.Field2
FROM Database1.User1.Table1 a
INNER JOIN Database2.User2.Table2 b ON a.KeyID = b.KeyID

Here is how an update query would look:
UPDATE a
SET a.Field1 = b.Field1
FROM Database1.User1.Table1 a
INNER JOIN Database2.User2.Table2 b ON a.KeyID = b.KeyID
0
 
LVL 10

Expert Comment

by:ksaul
ID: 18950635
Did that help?
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

726 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