Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_dbremove

  No additional text.


Syntax
create procedure sys.sp_dbremove --- 1996/04/08 00:00
	@dbname sysname = null,
	@dropdev varchar(10) = null
as
	declare @dbid int
	declare @devname sysname
	declare @physname varchar(255)

	if @dbname is null
	begin
		raiserror(15131,-1,-1)
		return(1)
	end

	if lower(@dropdev) <> 'dropdev' and @dropdev is not null
	begin
		raiserror(15131,-1,-1)
		return(1)
	end

	-- You must be SA to execute this sproc.
	if (not (is_srvrolemember('sysadmin') = 1))
	begin
		raiserror(15247,-1,-1)
		return(1)
	end

	-- Make sure not trying to remove within a transaction.
	set implicit_transactions off
	if @@trancount > 0
	begin
		raiserror(15002,-1,-1,'sys.sp_dbremove')
		return(1)
	end

	-- Check to see if database exists.
	select @dbid = dbid from master.dbo.sysdatabases where name=@dbname
	if @dbid is null
	begin
		raiserror(15010,-1,-1,@dbname)
		return(1)
	end

	-- Make sure no one is in the db.
	if (select count(*) from master.dbo.sysprocesses where dbid = @dbid) > 0
	begin
		raiserror(15069,-1,-1)
		return (1)
	end

	-- Note: database @dbname may not exist anymore
	-- If invoke gets error, exception will abort this proc.
	EXEC %%DatabaseRef(Name = @dbname).SetSuspect(Value = 1)

	declare @dropCmd nvarchar(max)

	select @dropCmd = 'drop database ' + quotename(@dbname)
	exec (@dropCmd)
	raiserror(15458,-1,-1)

	return(0)	-- sp_dbremove

 
Last revision 2008RTM
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