首页 > 代码库 > MSSQL

MSSQL

DECLARE @dbname nvarchar(128)
SET @dbname = N‘database_name‘

IF NOT EXISTS (SELECT name FROM master.dbo.sysdatabases
     WHERE (‘[‘ + name + ‘]‘ = @dbname OR name = @dbname))
BEGIN
     CREATE DATABASE TuoTuo;
END

GO

 

 

IF (EXISTS (SELECT *                  FROM INFORMATION_SCHEMA.TABLES                  WHERE TABLE_SCHEMA = ‘TheSchema‘                  AND  TABLE_NAME = ‘TheTable‘))BEGIN    --Do StuffEND

MSSQL