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
 restricting a user

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-08-12 : 06:44:29
Dear all,
is there any way to restrict an user to view the records for a specific number?

i mean suppose i've 100 million records in my table. selecting the rows from that table will defnetly impact on the server. is there any way to restrict a particular user to select only 1 million records?



Arnav
Even you learn 1%, Learn it with 100% confidence.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-12 : 07:51:42
One way to do this is to create a view for the user to view only his interested records.
Go to Top of Page

NeilG
Aged Yak Warrior

530 Posts

Posted - 2008-08-12 : 08:18:22
You would have to create a seperate view for that user but if you are wanting it so that the user can only see a sample of records, have you thought about using a view and utilising the TOP command in the select statement something like

create view dbo.test
as
select top 20 percent col1, col2, col3
from table1


***************************
Life is for having Fun, and then a little work
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-08-12 : 08:27:01
thank you very much visakh and neilG, so that i can restrict the user for this particular table.

is this the only solution?


actually this is an interview question asked by IBM.

Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-08-12 : 08:30:42
i mean any option like grranting only 2000 rows or something else?

Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-12 : 08:31:19
yup...and also you could make procedure with a parameter to indicate number of records you want and then use
select top (@n) * from yourtable
to get top n records for passed n value.
but for this you need sql 2005 or later.
Go to Top of Page

NeilG
Aged Yak Warrior

530 Posts

Posted - 2008-08-12 : 08:43:46
or even an inline table function maybe

***************************
Life is for having Fun, and then a little work
Go to Top of Page
   

- Advertisement -