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
 how to set a limit on a view for update

Author  Topic 

Hommer
Aged Yak Warrior

808 Posts

Posted - 2014-03-26 : 17:26:54
Hi,

I am going to create a custom view (SQL08R2 now, but in SQL2012 later this year). One unusual feature is that someone suggested to limit the update capability to one column, and only allow certain number of rows to update, for instance in dev stage, 1 row at a time, and change it to allow 5 rows at a time when in production.

Could you build a trigger on a view?

What other options out here?

Thanks!

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2014-03-26 : 17:42:42
I don't know of a way to do this at the View level, per se, but you could accomplish at the GRANT level. Instead of issuing a GRANT UPDATE on the entire View, limit it to the column.[CODE]GRANT SELECT on OBJECT::MyView to MyUserOrRole;
GRANT UPDATE(MyColumn) on OBJECT::MyView to MyUserOrRole;[/CODE]This wouldn't stop users with elevated rights(e.g., sysadmin) but would allow you to expose all columns of the View for SELECT but only your special column for UPDATE.

===============================================================================
“Everyone wants a better life: very few of us want to be better people.”
-Alain de Botton
Go to Top of Page

Hommer
Aged Yak Warrior

808 Posts

Posted - 2014-03-27 : 09:43:30
Great idea, thank you!
Go to Top of Page
   

- Advertisement -