Solved

How to update this stored procedure?

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Slow Connectivity over ODBC 8 36
SQL SELECT query help 7 41
insert wont work in SQL 14 22
SQL server vNext 18 29
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

810 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