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
 SQL Sever side query to filter for user ID

Author  Topic 

homeguard
Starting Member

32 Posts

Posted - 2008-04-23 : 14:05:12

I currently have a query in an access database that filters the records in a Sql Linked table for their user ID. So basically i use Environ("UserName") to filter for a field that contains their user name. I want to secure this and put it on the SQL Server so there is no way anyone can see any records other then the ones that are filtered for them. Does anyone know how to do this? I think it will be some SQL query.

I'm still learning sql server 2005.

Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-04-23 : 14:08:32
Post an example of what you mean.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-23 : 14:22:37
You can make a VIEW and put a WHERE filter over some column and compare with SQL login account.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

homeguard
Starting Member

32 Posts

Posted - 2008-04-23 : 15:33:30
Here is the query that i am using in access:

SELECT dbo_tblAITInfo.Key, dbo_tblAITInfo.RxNum, dbo_tblAITInfo.OrdNum, dbo_tblAITInfo.OrdCell, dbo_tblAITInfo.ErCode, dbo_tblAITInfo.SubmitDate, dbo_tblAITInfo.AITDate, dbo_tblAITInfo.TechInt, dbo_tblAITInfo.TechCellNum, dbo_tblAITInfo.Comments, dbo_tblAITInfo.SS, dbo_tblUsers.userID
FROM dbo_tblUsers INNER JOIN dbo_tblAITInfo ON dbo_tblUsers.userInitials = dbo_tblAITInfo.TechInt
WHERE (((dbo_tblUsers.userID)=Environ("UserName")));

I have the linked tables pulled into the access database with a single sql login account. Is there any way to compare the column to the user ID of the person logged into the computer instead of the sql login account name?
Go to Top of Page
   

- Advertisement -