Re: sp_revokedbaccess
From: Lisa (anonymous_at_discussions.microsoft.com)
Date: 12/31/03
- Next message: Tuoc: "Password protected BAK Files"
- Next in thread: Dan Guzman: "Re: sp_revokedbaccess"
- Reply: Dan Guzman: "Re: sp_revokedbaccess"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 31 Dec 2003 08:18:46 -0800
Here is the code, the primary difference being the
existence of @error:
CREATE procedure sp_RevokeDBAccess
@name_in_db sysname,
@error int OUT
as
Set @error = 0
-- SETUP RUNTIME OPTIONS / DECLARE VARIABLES --
set nocount on
declare @uid smallint,
@ret int
-- CHECK PERMISSIONS --
if (not is_member('db_accessadmin') = 1) and
(not is_member('db_owner') = 1)
begin
Set @error = 15000
--print '@error = ' + convert ( varchar (6), @error )
return (1)
end
-- DISALLOW USER TRANSACTION --
set implicit_transactions off
IF (@@trancount > 0)
begin
Set @error = 15002
--print '@error = ' + convert ( varchar (6), @error )
return (1)
end
-- CHECK IF SYSUSER EXISTS --
select @uid = uid from sysusers where name =
@name_in_db
and (issqluser = 1 or isntname =
1) -- is droppable entity
and (name <> 'guest' or hasdbaccess =
1) -- special case guest
if @uid is null
begin
Set @error = 15008
-- print '@error = ' + convert ( varchar (6),
@error )
return (1)
end
if @error = 0
begin
exec @error = sp_revokedbaccess @name_in_db
end
GO
- Next message: Tuoc: "Password protected BAK Files"
- Next in thread: Dan Guzman: "Re: sp_revokedbaccess"
- Reply: Dan Guzman: "Re: sp_revokedbaccess"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|