Solved

Need help finishing view/query for SQL backend

Posted on 2007-04-10
2
160 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
  • 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

776 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