Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

How to update this stored procedure?

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
angus_young_acdc
Asked:
angus_young_acdc
1 Solution
 
udaya kumar laligondlaTechnical LeadCommented:
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
 
angus_young_acdcAuthor Commented:
Thanks :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now