Solved

using suser_sname() in a view to get data.

Posted on 2004-09-29
4
759 Views
Last Modified: 2011-09-20

I have two users logging into SQL Server and I want to use suser_sname() (if that is correct) to select data from within a view so that:

if the table data is say:

x,x,x,x,0
x,x,x,x,0
x,x,x,x,1

I want to create a view to:

if user1 then view all records where 0 in the final field
if user2 then view all records.

but how do you do that in a view? help :)

Thanks
0
Comment
Question by:gabbs1
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
create view YourView
as
select *
from yourtable
where suser_sname() = 'user2'
or FinalFieldCol = 0

CHeers
0
 
LVL 12

Accepted Solution

by:
geotiger earned 250 total points
Comment Utility
It should be

create view YourView
as
select *
from yourtable
where (suser_sname() = 'user2'
and FinalFieldCol = 0)
OR
(suser_sname() = 'user1'
and FinalFieldCol = 1)
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
geotiger, are you sure ?
>>if user2 then view all records.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
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.

743 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

8 Experts available now in Live!

Get 1:1 Help Now