Create the Procedure
Compile the procedure
Run the procedure: -
EXEC usp_checkdb @dbname = 'Enter DB'
Create the Procedure
Compile the procedure
Run the procedure: -
EXEC usp_checkdb @dbname = 'Enter DB'
CREATE procedure usp_checkdb (@dbname nvarchar(128)) as begin /* Check, How to Run: EXEC usp_checkdb @dbname = 'Enter DB' */ IF (EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE ('[' + name + ']' = @dbname OR name = @dbname))) SELECT 'YES' IF (NOT EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE ('[' + name + ']' = @dbname OR name = @dbname))) SELECT 'No' END