Solved

How to update this stored procedure?

Posted on 2009-04-02
2
142 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

706 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

18 Experts available now in Live!

Get 1:1 Help Now