Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_dropdevice

  No additional text.


Syntax
create procedure sys.sp_dropdevice --- 1996/04/08 00:00
	@logicalname	sysname,		-- logical name of the device
	@delfile	varchar(7) = null	-- optional param. to delete disk file
as
	declare @delfileIn varchar(7)
	select @delfileIn = @delfile
	-- See if user specified something for @delfile and, if so, validate it.
	if @delfile is not null
	begin
		select @delfile = lower(@delfile collate Latin1_General_CI_AS)
		if @delfile <> 'delfile'
		begin
			raiserror(15216,-1,-1,@delfileIn)
			return(1)
		end
	end

	-- If we're in a transaction, disallow this since it might make recovery impossible.
	set implicit_transactions off
	if @@trancount > 0
	begin
		raiserror(15002,-1,-1,'sys.sp_dropdevice')
		return (1)
	end

	-- Only the system administrator (SA) can run this command.
	--  Check to make sure the executor is the sa.
	if not is_srvrolemember('diskadmin') = 1
	begin
		raiserror(15247,-1,-1)
		return (1)
	end

	-- Check and make sure that the device actually exists.
	if not exists (select * from master.dbo.sysdevices where name = @logicalname)
	begin
		raiserror(15012,-1,-1,@logicalname)
		return (1)
	end

	-- Drop the device.
	if @delfile = 'delfile'
		dbcc dbrepair
		('', 'dropdevice',@logicalname, 1)  WITH NO_INFOMSGS
	else
		dbcc dbrepair
		('', 'dropdevice',@logicalname, 0)  WITH NO_INFOMSGS

	if @@error <> 0
		return (1)

	raiserror(15463,-1,-1)

	return (0) -- sp_dropdevice

 
Last revision 2008RTM
See also

  sp_dropdistributiondb (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