Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_droprole

  No additional text.


Syntax
create procedure sys.sp_droprole
    @rolename       sysname     -- role to be dropped
as
    -- SETUP RUNTIME OPTIONS / DECLARE VARIABLES 
	set nocount on
	declare @ret        int,
            @stmtR		nvarchar(4000)

    -- DISALLOW USER TRANSACTION 
	set implicit_transactions off
	if (@@trancount > 0)
	begin
		raiserror(15002,-1,-1,'sys.sp_droprole')
		return (1)
	end

	exec @ret = sys.sp_validname @rolename
	if @ret <> 0
		return(1)

	-- create statement
	set @stmtR = 'drop role '   + quotename(@rolename)
	
	BEGIN TRANSACTION

	-- this will drop the schema owned by the role that has the same name as the role,
	-- if such schema exists
	EXEC %%Owner(Name = @rolename).DropSchema(OwnerType = 2)
	if @@error <> 0
	begin
		ROLLBACK TRANSACTION
		-- error message comes from inside the invoke
		return (1)
	end

	-- drop the role
	exec (@stmtR)
	if @@error <> 0
	begin
		ROLLBACK TRANSACTION
		-- error message comes from inside the statement
		return (1)
	end

	COMMIT TRANSACTION

    -- RETURN SUCCESS 
    return (0) -- sp_droprole

 
Last revision 2008RTM
See also

  sp_cdc_drop_objects (Procedure)
sp_changegroup (Procedure)
sp_dropgroup (Procedure)
sp_droprolemember (Procedure)
sp_MSdropmergepalrole (Procedure)
sp_MSdroptranpalrole (Procedure)
sp_MSmergepublishdb (Procedure)
sp_MSpublishdb (Procedure)
sp_MSremovedbreplication (Procedure)
sp_MSreplrole (Procedure)
sp_MSrepl_dbrole (Procedure)
sp_MSrepl_drop_all_role_members (Procedure)
sp_revoke_publication_access (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash