Re: permissions resetting on a View

From: Gregory A. Larsen (greg.larsen_at_netzero.com)
Date: 07/12/04


Date: Mon, 12 Jul 2004 14:20:23 -0700

Since the sp_renameview is a system store procedure, I'm not exactly sure
whether it drops and recreates the view. I did a little test I did, when
you run the sp_refreshview it appears to keep the permissions on a view.

If you really want to create or alter a view via a stored procedure you can
do that with dynamic SQL. Something like so:

create procedure yoursp as
declare @cmd char(1000)
set @cmd = 'alter view yourview as select bing, bang, boom from yourtable'
exec(@cmd)
--- rest of sp

-- 
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Terrell Miller" <millerto@bellsouth.net> wrote in message
news:2b1a001c4682f$259d8b90$a501280a@phx.gbl...
>
> >-----Original Message-----
> >When you delete a Role or a View, or any other object for
> that matter,  you
> >also delete the permissions associated with those
> objects.  If you what to
> >keep the permissions for the View then don't delete the
> view and recreate,
> >but instead just ALTER the view.  When you ALTER an
> object the permissions
> >that are associated with the object stay intact.
>
> Greg, we aren't changing the view or the roles. It's just
> that from time to time the Select permission on that View
> gets removed.
>
> Question: when you use sp_refreshview does that actually
> delete the view and recreate it? I can't set up an ALTER
> inside a sproc (because the ALTER has to be the first line
> in a batch, but the CREATE PROCEDURE statement has to
> execute before it), which is why I'm using sp_refreshview.
>
> Thanks again,
>
> Terrell


Relevant Pages

  • Re: permissions resetting on a View
    ... that matter, you ... >keep the permissions for the View then don't delete the ... >but instead just ALTER the view. ... delete the view and recreate it? ...
    (microsoft.public.sqlserver.server)
  • Re: permissions resetting on a View
    ... When you delete a Role or a View, or any other object for that matter, you ... also delete the permissions associated with those objects. ... When you ALTER an object the permissions ... "Terrell Miller" wrote in message ...
    (microsoft.public.sqlserver.server)
  • Re: Cannot write to shared folder on W2K8 server
    ... After reading your latest post and Meinolf about how you cannot recreate my issues led me to try to recreate it myself. ... I created a new folder and share on C: and can write to it from my desktop. ... Which I still don't understand why it doesn't work especially if I had reapplied the share permissions and NTFS security. ... If that was the case, maybe removing the share and NTFS permissions, except for administrator, and then reapply the NTFS permissions, then the Share. ...
    (microsoft.public.windows.server.general)
  • Re: DDL Permissions - CREATE PROCEDURE, but no CREATE TABLE
    ... Sorry, you are correct, I misread the original message. ... if you want this person to use the dbo user. ... > reponse is angled towards data access permissions. ... > to CREATE, ALTER, or DROP tables or other objects. ...
    (microsoft.public.sqlserver.security)
  • Re: How to determine if a user has a permission programmatically?
    ... I need to determine in advance if a user logged on to SQL Server 2005 can ... sp_addrolemember and ALTER LOGIN). ... determine programmatically if a user has specific permissions (ALTER ANY ...
    (microsoft.public.sqlserver.security)