dbTalk Databases Forums  

Help setting up a view

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Help setting up a view in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
JJ297
 
Posts: n/a

Default Help setting up a view - 02-07-2008 , 02:27 PM






How do I set up a sql statement to use as a view?

I want to use two tables but they are both from different databases.

From the Offices database I want to use a table called Office Code and
only the Name column

The other database is called Library and I want to use a table called
Requestors and join it to others.

I've set the stored procedure up that I want to use to get most of the
data besides the data in the offices database.

Create view GetDataview

select requestors.officeCode, requestors.Fname + ' ' +
requestors.Lname as [Name], Titles.title as Title
from requestors

join libraryrequest on libraryrequest.requestorid =
requestors.requestorid
join Titles on Titles.Titleid = libraryrequest.Titleid
where officecode <> 0
order by Officecode
GO

How do I add the database offices, table officecodes to this view to
use the Name column?

I hope this makes sense


Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Help setting up a view - 02-07-2008 , 04:20 PM






JJ297 (nc297 (AT) yahoo (DOT) com) writes:
Quote:
How do I set up a sql statement to use as a view?

I want to use two tables but they are both from different databases.

From the Offices database I want to use a table called Office Code and
only the Name column

The other database is called Library and I want to use a table called
Requestors and join it to others.
You refer to a table in a different database with three-part notation.
For instance:

Offices.dbo.[Office Code]


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #3  
Old   
JJ297
 
Posts: n/a

Default Re: Help setting up a view - 02-08-2008 , 06:39 PM



On Feb 7, 5:20 pm, Erland Sommarskog <esq... (AT) sommarskog (DOT) se> wrote:
Quote:
JJ297 (nc... (AT) yahoo (DOT) com) writes:
How do I set up a sql statement to use as a view?

I want to use two tables but they are both from different databases.

From the Offices database I want to use a table called Office Code and
only the Name column

The other database is called Library and I want to use a table called
Requestors and join it to others.

You refer to a table in a different database with three-part notation.
For instance:

Offices.dbo.[Office Code]

--
Erland Sommarskog, SQL Server MVP, esq... (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Thanks I got it! I didn't give my user permissions to use the other
table.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.