Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_dropuser

  No additional text.


Syntax
create procedure sys.sp_dropuser
	@name_in_db     sysname     -- user name to drop
as
    -- SETUP RUNTIME OPTIONS / DECLARE VARIABLES 
	set nocount on
    declare @ret    int
    declare @targetName sysname
    -- LIMIT TO SQL/NT USERS (BCKWRD COMPAT ONLY!)
    if not exists (select * from sysusers where name = @name_in_db
                    and (isntuser = 1 or isntname = 0))
    begin
        raiserror(15008,-1,-1,@name_in_db)
        return (1)
    end
    -- store target name
    select  @targetName = (select sl.name from master..syslogins sl,sysusers su where su.name = @name_in_db and su.sid = sl.sid)

    -- DROP THE USER FROM THE DATABASE 
    EXEC @ret = sys.sp_revokedbaccess @name_in_db
    if @ret <> 0
    begin
        -- AUDIT FAILED SECURITY CHECK
	    dbcc auditevent (109, 2, 0, @targetName, @name_in_db, NULL, NULL, NULL, NULL, NULL)
        return (1)
    end

    -- AUDIT SUCCESSFUL SECURITY CHECK 
    dbcc auditevent (109, 2, 1, @targetName, @name_in_db, NULL, NULL, NULL, NULL, NULL)

    -- FINALIZATION: PRINT/RETURN SUCCESS 
    return (0) -- sp_dropuser

 
Last revision 2008RTM
See also

  sp_droppullsubscription (Procedure)
sp_link_publication (Procedure)
sp_remove_log_shipping_monitor_account (Procedure)
sp_subscription_cleanup (Procedure)
sp_unlink_publication (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