We can use the sys.sysdatabases catalog view to check the existence of a Database.
Here in the below script we are checking the existence of the Database Mduaccountsmas.
Example:
Here in the below script we are checking the existence of the Database Mduaccountsmas.
Example:
IF EXISTS(SELECT * FROM master.sys.sysdatabases
WHERE name='Mduaccountsmas')
BEGIN
PRINT 'Exists'
END
else
begin
PRINT 'Exists'
End
Result:
0 Comments