Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_resetstatus

  No additional text.


Syntax

create procedure sys.sp_resetstatus  -- 1995/11/30 14:12 #12092
	@DBName sysname
as
	set nocount on
	declare @state int
	declare @source_dbid int

	-- RESTRICT TO SA 
	if (not (is_srvrolemember('sysadmin') = 1))
	begin
	   raiserror(15247,-1,-1)
	   return (1)
	end

	-- FORBID ACTIVE TXN 
	set implicit_transactions off
	if @@trancount > 0
	begin
	   raiserror(15002,-1,-1,'sys.sp_resetstatus')
	   return (1)
	end

	
	-- Make sure the db exists
	
	if not exists (select * from master.sys.databases where name = @DBName)
	begin
		raiserror(15010,-1,-1,@DBName)
		return (1)
	end

	select @state = state,
	@source_dbid = source_database_id
	from master.sys.databases
	where name = @DBName

	
	-- Cannot reset a database snapshot.  Anything but NULL or 0
	-- is a snapshot.
	
	if (ISNULL(@source_dbid, 0) <> 0)
	begin
		raiserror(15658,-1,-1)
		return (1)
	end
	
	
	-- Must already be suspect.  4 is SUSPECT state.
	
	if (@state <> 4)
	begin
		raiserror(15056,-1,-1,@DBName)
		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 = 0)

	-- Warning: You must recover this database prior to access.
	raiserror(15074,-1,-1)

	return (0) -- sp_resetstatus

 
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