我想從我發送的SQL查詢中創建一個數據庫。應該指出SQL不是我的強項。從查詢中創建數據庫時出錯
以下是在查詢開始宣稱:
:setvar DatabaseName "Database"
:setvar DefaultDataPath ""
:setvar DefaultLogPath ""
我已經運行在命令模式下查詢並正在以下錯誤:
Creating Database...
Msg 5105, Level 16, State 2, Line 1
A file activation error occurred. The physical file name 'DB.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.Msg 1802, Level 16, State 1, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
An error was encountered during execution of batch. Exiting.
任何想法?因爲很長,而且包含敏感信息,但被砍倒版本多達似乎導致錯誤點
感謝
不能發佈完整的查詢。
SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;
SET NUMERIC_ROUNDABORT OFF;
GO
:setvar DatabaseName "Database"
:setvar DefaultDataPath ""
:setvar DefaultLogPath ""
GO
:on error exit
GO
USE [master]
GO
IF (DB_ID(N'$(DatabaseName)') IS NOT NULL
AND DATABASEPROPERTYEX(N'$(DatabaseName)','Status') <> N'ONLINE')
BEGIN
RAISERROR(N'The state of the target database, %s, is not set to ONLINE. To deploy to this database, its state must be set to ONLINE.', 16, 127,N'$(DatabaseName)') WITH NOWAIT
RETURN
END
GO
IF (DB_ID(N'$(DatabaseName)') IS NOT NULL)
BEGIN
ALTER DATABASE [$(DatabaseName)]
SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE [$(DatabaseName)];
END
GO
PRINT N'Creating $(DatabaseName)...'
GO
CREATE DATABASE [$(DatabaseName)]
ON
PRIMARY(NAME = [DB], FILENAME = '$(DefaultDataPath)DB.mdf', SIZE = 3072 KB, FILEGROWTH = 1024 KB)
LOG ON (NAME = [DB_log], FILENAME = '$(DefaultLogPath)DB_log.ldf', SIZE = 1024 KB, MAXSIZE = 2097152 MB, FILEGROWTH = 10 %) COLLATE SQL_Latin1_General_CP1_CI_AS
GO
EXECUTE sp_dbcmptlevel [$(DatabaseName)], 100;
你能告訴我們**那個查詢!?!??否則,我們只是猜測.... – 2012-03-12 12:37:11
我們將需要完整的T-SQL語句。 – 2012-03-12 12:37:54