?
Solved

Need help finishing view/query for SQL backend

Posted on 2007-04-10
2
Medium Priority
?
167 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 2000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

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