Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need HelpTrying to inser a new field inside a view

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2009-07-08 : 13:55:19
I have a view that is connected to a Master Table. This view has the following Columns:

App_Name----Approver_UserID------BackUp_UserID------
HR Payroll MRobert02 TSmith01


There is another table called Active_Directory that contains the User_ID + Email Accounts.

What I need to do is the following:


App_Name----Approver_UserID---Approver_Mail ---BackUp_UserID------BackUP_Mal
HR Payroll MRobert02 MRobert02@mynet.com TSmith01 TSmith01@mynet.com


How can I join the Active_Directory Table with the View on both places Approver_UserID and BackUp_UserID so I can pass those values for the new two columns (Approver_Mail) and (BackUP_Mail)

Thanks for the Help

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-08 : 13:59:47
[code]
CREATE VIEW yooutview
AS
SELECT m.App_Name,
m.Approver_UserID,
ad2.Email AS Approver_Mail,
m.BackUp_UserID,
ad1.Email AS BackUP_Mal
FROM Master m
INNER JOIN Active_Directory ad1
ON ad1.User_ID=m.BackUp_UserID
INNER JOIN Active_Directory ad2
ON ad2.User_ID=m.Approver_UserID
[/code]
Go to Top of Page
   

- Advertisement -