日期:2014-05-17 浏览次数:20873 次
USE [master]
GO
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'YourDatabaseName')
DECLARE @dbname nvarchar(128)
SET @dbname = N'aa'
IF (EXISTS (SELECT name
FROM master.dbo.sysdatabases
WHERE ('[' + name + ']' = @dbname
OR name = @dbname)))
-- code mine :)
PRINT 'db exists'