Solved

How to update this stored procedure?

Posted on 2009-04-02
2
152 Views
Last Modified: 2012-05-06
As a follow on from my previous question (accepted before asking this!), how could I do an inner join on the status?  

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL-Server-2005/Q_24287818.html#a24047918

The dbo.Users.Status will be 7, but in the UsersTypes table 7 means "Administrator".  How can I do a join for my where clause so that if the status number (which is a row ID) ever changes it won't cause an issue.  EG having something like:

WHERE(dbo.Users.Status = dbo.UsersTypes.Code = "Administrator"

Or however you would do a join on that.
0
Comment
Question by:angus_young_acdc
2 Comments
 
LVL 12

Accepted Solution

by:
udayakumarlm earned 500 total points
ID: 24048082
I am assuming that you have dbo.UserTypes table which is having the userName as relation to the user table. if so use the code. if the field names are changed then use the same.
publish the table structures if more help needed

SELECT 

dbo.Users.UserName AS UserName, 

dbo.FileName.FileName

FROM dbo.Users 

INNER JOIN dbo.FileName ON dbo.Users.UserName = dbo.FileName.FilePrintStatus 

inner Join  dbo.UserTypes ON dbo.Users.UserName =  ON dbo.UsersTypes.UserName 

WHERE (dbo.UserTypes.Code = 'Administrator')

Open in new window

0
 
LVL 15

Author Closing Comment

by:angus_young_acdc
ID: 31565709
Thanks :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now