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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 select with a condition

Author  Topic 

snb123
Starting Member

1 Post

Posted - 2009-10-11 : 18:18:01
In a view, I'm trying to modify a select. I want add to the select using the current_user or session_user.

Example: We have a find form where I can enter a portion of the company's name like Ap. It will select all companies that start with Ap. Great

Instead I want to select all company's name that start with Ap and also where the companies.salesrep equals current_user. I would also like if the current_user is 'admin' then select all company's that start with Ap. companies.salesrep is already added to the companies table and populated with the same data as the sql login username.

would the below statment work:

Where dbo.companies.salesrep = current_user or current_user = 'admin'

sanoj_av
Posting Yak Master

118 Posts

Posted - 2009-10-12 : 00:04:57
Where dbo.companies.salesrep = system_user
Go to Top of Page
   

- Advertisement -