我在尝试部署数据库项目时遇到错误。我正在使用SQL Server 2008 R2和VS 2010.以下是我收到的错误消息。
D:\ Solutions \ MyDatabase \ sql \ debug \ Database.sql(81,0):错误SQL01268: .Net SqlClient数据提供程序:消息911,级别16,状态4,过程 COUNTRY $ CurrvalSupport,第18行数据库'sysdb'不存在。使 确保正确输入名称。
我检查了我的整个解决方案,发现没有提到sysdb。我无法理解那里发生的事情。任何有关这方面的帮助将不胜感激。
以下是Database.sql文件的内容。
/*
Deployment script for I2
*/
GO
SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;
SET NUMERIC_ROUNDABORT OFF;
GO
:setvar I2RDB "I2RDB"
:setvar DatabaseName "I2"
:setvar DefaultDataPath "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\"
:setvar DefaultLogPath "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\"
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 NOT EXISTS (SELECT 1 FROM [master].[dbo].[sysdatabases] WHERE [name] = N'$(DatabaseName)')
BEGIN
RAISERROR(N'You cannot deploy this update script to target LALIT1507. The database for which this script was built, I2, does not exist on this server.', 16, 127) WITH NOWAIT
RETURN
END
GO
IF (@@servername != 'LALIT1507')
BEGIN
RAISERROR(N'The server name in the build script %s does not match the name of the target server %s. Verify whether your database project settings are correct and whether your build script is up to date.', 16, 127,N'LALIT1507',@@servername) WITH NOWAIT
RETURN
END
GO
IF CAST(DATABASEPROPERTY(N'$(DatabaseName)','IsReadOnly') as bit) = 1
BEGIN
RAISERROR(N'You cannot deploy this update script because the database for which it was built, %s , is set to READ_ONLY.', 16, 127, N'$(DatabaseName)') WITH NOWAIT
RETURN
END
GO
USE [$(DatabaseName)]
GO
/*
Pre-Deployment Script Template
--------------------------------------------------------------------------------------
This file contains SQL statements that will be executed before the build script.
Use SQLCMD syntax to include a file in the pre-deployment script.
Example: :r .\myfile.sql
Use SQLCMD syntax to reference a variable in the pre-deployment script.
Example: :setvar TableName MyTable
SELECT * FROM [$(TableName)]
--------------------------------------------------------------------------------------
*/
/*------------------------------------------------------------------------------------
Scripts for Infolink 2.2 (oracle) to Infolink 2.3 migration
-------------------------------------------------------------------------------------
*/
Print 'Updating null values for dbo.[PROTOCOCOL].[NO_IP_SHIPMENTS_REQUIRED]...'
UPDATE PROTOCOL SET NO_IP_SHIPMENTS_REQUIRED = 0 WHERE NO_IP_SHIPMENTS_REQUIRED is null;
GO
-- Refactoring step to update target server with deployed transaction logs
GO
/*
Post-Deployment Script Template
--------------------------------------------------------------------------------------
This file contains SQL statements that will be appended to the build script.
Use SQLCMD syntax to include a file in the post-deployment script.
Example: :r .\myfile.sql
Use SQLCMD syntax to reference a variable in the post-deployment script.
Example: :setvar TableName MyTable
SELECT * FROM [$(TableName)]
--------------------------------------------------------------------------------------
*/
/* ADD DATA READER ROLE TO I2 (used on developer boxes
--------------------------------------------------------------------------------------*/
EXEC sp_addrolemember 'db_datareader', 'I2'
GO
/* ADD DATA WRITE ROLE TO I2 (used on developer boxes)
--------------------------------------------------------------------------------------*/
EXEC sp_addrolemember 'db_datawriter', 'I2'
GO
/* SPLIT Czechoslovokia INTO TWO COUNTRIES
--------------------------------------------------------------------------------------*/
UPDATE COUNTRY SET COUNTRY_NAME = 'Czech Republic' WHERE COUNTRY_NAME = 'Czechoslovakia'
GO
IF (select count (*) from [dbo].[COUNTRY] WHERE COUNTRY_NAME = 'Slovakia') < 1
BEGIN
INSERT INTO [dbo].[COUNTRY]
([ISO_COUNTRY_CODE]
,[COUNTRY_NAME]
,[INTERNATIONAL_CALLING_CODE]
,[STATE_DENOMINATION]
,[IORDER]
,[OWNER]
,[LAST_USER]
,[DATE_CREATED]
,[DATE_MODIFIED]
,[DATE_START]
,[VERSION]
,[ENTITY_ID]
,[RECORD_STATUS])
VALUES
(
'SK'
,'Slovakia'
,421
,'None'
,152
,NULL
,NULL
,GETDATE()
,GETDATE()
,GETDATE()
,0
,0
,0
)
END
GO
-- M Hardeman - 8/1/2011 - Make sure that the existing protocols have the appropriate PROTOCOL_STATUS record (originals were done in script, and didn't have any)
-- B Dickson - 06-0CT-2011 - I was wondering why there was 13 million rows in protocol table for the dev db.
--UPDATE PROTOCOL SET PROTOCOL_STATUS = 'Deleted' WHERE RECORD_STATUS = 2
--GO
--UPDATE PROTOCOL SET PROTOCOL_STATUS = 'Inactive' WHERE RECORD_STATUS = 1
--GO
-- N Craver 8/30/2011 - Sync all code list items that exist in Documents to Track but not Document Type
Insert Into CODE_LIST_ITEM (PROTOCOL_ID, REF_NAME, CODE_LIST_ITEM_VALUE, CODE_LIST_ITEM_TEXT, I_ORDER, CODE_LIST_ITEM_TYPE,
[OWNER], LAST_USER, DATE_CREATED, [VERSION], ENTITY_ID, RECORD_STATUS, IS_CUSTOMIZABLE, DATE_START)
SELECT [PROTOCOL_ID]
,Replace(Ref_Name, 'DocumentsToTrack_', 'DocumentType_')
,[CODE_LIST_ITEM_VALUE]
,[CODE_LIST_ITEM_TEXT]
,[I_ORDER]
,'DocumentType'
,[OWNER]
,[LAST_USER]
,GETDATE()
,1
,[ENTITY_ID]
,[RECORD_STATUS]
,[IS_CUSTOMIZABLE]
,GETDATE()
FROM [I2].[dbo].[CODE_LIST_ITEM] cli
WHERE CODE_LIST_ITEM_TYPE = 'DocumentsToTrack'
And Not Exists(Select 1
From CODE_LIST_ITEM dttcli
Where cli.CODE_LIST_ITEM_TEXT = dttcli.CODE_LIST_ITEM_TEXT
And cli.PROTOCOL_ID = dttcli.PROTOCOL_ID
And dttcli.CODE_LIST_ITEM_TYPE = 'DocumentType')
GO
IF (select count (*) from [dbo].[STUDY_ISSUE_STATUS] WHERE NAME = 'Opened') < 1
BEGIN
INSERT INTO [dbo].[STUDY_ISSUE_STATUS]
([PROTOCOL_ID]
,[NAME]
,[DESCRIPTION]
,[DATE_CREATED]
,[LAST_USER]
,[DATE_MODIFIED]
,[ENTITY_ID]
,[RECORD_STATUS]
,[OWNER])
VALUES
(
(SELECT TOP(1) ID FROM PROTOCOL)
,'Opened'
,'The issue has been opened'
,GETDATE()
,'I2'
,NULL
,0
,0
,NULL
)
END
IF (select count (*) from [dbo].[STUDY_ISSUE_STATUS] WHERE NAME = 'Closed') < 1
BEGIN
INSERT INTO [dbo].[STUDY_ISSUE_STATUS]
([PROTOCOL_ID]
,[NAME]
,[DESCRIPTION]
,[DATE_CREATED]
,[LAST_USER]
,[DATE_MODIFIED]
,[ENTITY_ID]
,[RECORD_STATUS]
,[OWNER])
VALUES
(
(SELECT TOP(1) ID FROM PROTOCOL)
,'Closed'
,'The issue is closed'
,GETDATE()
,'I2'
,NULL
,0
,0
,NULL
)
END
GO
-- M Hardeman - Fix for bug number 1428 - adding a new dropdown for Pending CSA/Budget to the dropdown menu for IRB status on
-- Protocol Site IRB/EC Approval Renewal Page
IF (select count (*) from [dbo].CODE_LIST_ITEM WHERE CODE_LIST_ITEM_VALUE = 'Pending CSA/Budget' AND CODE_LIST_ITEM_TYPE = 'IrbEcApprovalStatus') < 1
BEGIN
UPDATE CODE_LIST_ITEM SET REF_NAME = 'IrbEcApprovalStatus_6' WHERE REF_NAME = 'IrbEcApprovalStatus_5' And Entity_Id = 0
UPDATE CODE_LIST_ITEM SET I_ORDER = 6 WHERE REF_NAME = 'IrbEcApprovalStatus_6' And Entity_Id = 0
INSERT INTO CODE_LIST_ITEM
(
PROTOCOL_ID,
REF_NAME,
CODE_LIST_ITEM_VALUE,
CODE_LIST_ITEM_TEXT,
I_ORDER,
CODE_LIST_ITEM_TYPE,
[OWNER],
LAST_USER,
DATE_CREATED,
[VERSION],
ENTITY_ID,
RECORD_STATUS,
IS_CUSTOMIZABLE,
DATE_START
)
VALUES
(
0
,'IrbEcApprovalStatus_5'
,'Pending CSA/Budget'
,'Pending CSA/Budget'
,5
,'IrbEcApprovalStatus'
,'No user logged'
,'No user logged'
,GETDATE()
,1
,0
,0
,0
,NULL
)
INSERT INTO CODE_LIST_ITEM
(
PROTOCOL_ID,
REF_NAME,
CODE_LIST_ITEM_VALUE,
CODE_LIST_ITEM_TEXT,
I_ORDER,
CODE_LIST_ITEM_TYPE,
[OWNER],
LAST_USER,
DATE_CREATED,
[VERSION],
ENTITY_ID,
RECORD_STATUS,
IS_CUSTOMIZABLE,
DATE_START
)
VALUES
(
-1
,'IrbEcApprovalStatus_5'
,'Pending CSA/Budget'
,'Pending CSA/Budget'
,5
,'IrbEcApprovalStatus'
,'No user logged'
,'No user logged'
,GETDATE()
,1
,0
,0
,0
,NULL
)
END
GO
-- M Hardeman - 8/4/2011 - Fix for bug 1489, added two new dropdowns for contact role on protocol site
IF (select count (*) from [dbo].[ROLE_INFO] WHERE ROLE_NAME = 'Contract' AND ROLE_TYPE = 'ProtocolSite') < 1
BEGIN
INSERT INTO [dbo].[ROLE_INFO]
(
[ROLE_NAME]
,[OWNER]
,[LAST_USER]
,[DATE_CREATED]
,[DATE_MODIFIED]
,[DATE_START]
,[VERSION]
,[ENTITY_ID]
,[RECORD_STATUS]
,[PROTOCOL_ID]
,[ROLE_INFO_ID]
,[ROLE_TYPE]
,[IS_DEFAULT]
,[TEMPLATE_ID]
,[ROLE_INFO_XML]
)
VALUES
(
'Contract'
,'i2system'
,'i2system'
,GETDATE()
,GETDATE()
,GETDATE()
,1
,0
,0
,-1
,(SELECT ID FROM ROLE_INFO WHERE ROLE_NAME='Site Roles')
,'ProtocolSite'
,NULL
,NULL
,NULL
)
END
GO
IF (select count (*) from [dbo].[ROLE_INFO] WHERE ROLE_NAME = 'Budget' AND ROLE_TYPE = 'ProtocolSite') < 1
BEGIN
INSERT INTO [dbo].[ROLE_INFO]
(
[ROLE_NAME]
,[OWNER]
,[LAST_USER]
,[DATE_CREATED]
,[DATE_MODIFIED]
,[DATE_START]
,[VERSION]
,[ENTITY_ID]
,[RECORD_STATUS]
,[PROTOCOL_ID]
,[ROLE_INFO_ID]
,[ROLE_TYPE]
,[IS_DEFAULT]
,[TEMPLATE_ID]
,[ROLE_INFO_XML]
)
VALUES
(
'Budget'
,'i2system'
,'i2system'
,GETDATE()
,GETDATE()
,GETDATE()
,1
,0
,0
,-1
,(SELECT ID FROM ROLE_INFO WHERE ROLE_NAME='Site Roles')
,'ProtocolSite'
,NULL
,NULL
,NULL
)
END
GO
Update CODE_LIST_ITEM
Set CODE_LIST_ITEM_VALUE = '0|IND Safety Report' Where CODE_LIST_ITEM_VALUE = '0|IIND Safety Report' And CODE_LIST_ITEM_TYPE = 'DocumentType' And Entity_Id = 0
GO
-- Fix bug 1535
UPDATE CODE_LIST_ITEM
Set CODE_LIST_ITEM_TEXT = 'Pharmacovigilance', CODE_LIST_ITEM_VALUE = 'Pharmacovigilance'
Where CODE_LIST_ITEM_TEXT = 'Pharamcovigilance'
And CODE_LIST_ITEM_VALUE = 'Pharamcovigilance'
And CODE_LIST_ITEM_TYPE = 'Department'
And RECORD_STATUS = 0
And ENTITY_ID = 0
GO
If Not Exists(Select 1 From CODE_LIST_ITEM Where CODE_LIST_ITEM_TYPE = 'Department' And CODE_LIST_ITEM_TEXT = 'Study Startup' And PROTOCOL_ID In (0, -1))
Begin
INSERT INTO CODE_LIST_ITEM
(
PROTOCOL_ID,
REF_NAME,
CODE_LIST_ITEM_VALUE,
CODE_LIST_ITEM_TEXT,
I_ORDER,
CODE_LIST_ITEM_TYPE,
[OWNER],
LAST_USER,
DATE_CREATED,
[VERSION],
ENTITY_ID,
RECORD_STATUS,
IS_CUSTOMIZABLE,
DATE_START
)
Select 0, 'Department_24', 'Study Startup', 'Study Startup', 24, 'Department', 'No user logged', 'No user logged', GETDATE(), 1, 0, 0, 0, NULL
Union
Select -1, 'Department_24', 'Study Startup', 'Study Startup', 24, 'Department', 'No user logged', 'No user logged', GETDATE(), 1, 0, 0, 0, NULL
END
GO
--Fix for bug 1574
Update CODE_LIST_ITEM
Set RECORD_STATUS = 2
Where CODE_LIST_ITEM_TEXT In('SEV Confirmation Letter', 'SEV Follow-up Letter', 'Site Evaluation Visit Report',
'SIV Confirmation Letter', 'SIV Follow-up Letter', 'Site Initiation Visit Report',
'IMV Confirmation Letter', 'IMV Follow-up Letter', 'Interim Monitoring Visit Report', '(020) Interim Monitoring Visit Report',
'COV Confirmation Letter', 'COV Follow-up Letter', 'Closeout Visit Report')
And CODE_LIST_ITEM_TYPE In ('DocumentType')
And RECORD_STATUS <> 2
And ENTITY_ID = 0
GO
--Adding NA to Site Document Status Dropdown
If Not Exists(SELECT 1 From CODE_LIST_ITEM Where CODE_LIST_ITEM_TEXT = 'N/A' AND
CODE_LIST_ITEM_TYPE='DocumentStatus')
Begin
INSERT INTO CODE_LIST_ITEM
(
CODE_LIST_ITEM_VALUE,
CODE_LIST_ITEM_TEXT,
CODE_LIST_ITEM_TYPE,
PROTOCOL_ID,
REF_NAME,
I_ORDER,
OWNER,
LAST_USER,
VERSION,
IS_CUSTOMIZABLE
)
VALUES
(
'N/A',
'N/A',
'DocumentStatus',
'-1',
'DocumentStatus_3',
'3',
'No user logged',
'No user logged',
'1',
'0'
)
END
GO
UPDATE Code_LIST_ITEM
SET PROTOCOL_ID='0'
WHERE PROTOCOL_ID='-1'
AND CODE_LIST_ITEM_TEXT='N/A'
AND CODE_LIST_ITEM_TYPE='DocumentStatus';
GO
--Fix for bug 1589
/*If Not Exists(SELECT 1 From CODE_LIST_ITEM Where CODE_LIST_ITEM_TEXT = 'Regulatory Contact' AND CODE_LIST_ITEM_TYPE='ProtocolSiteTitle')
Begin
INSERT INTO CODE_LIST_ITEM
(
CODE_LIST_ITEM_VALUE,
CODE_LIST_ITEM_TEXT,
CODE_LIST_ITEM_TYPE,
PROTOCOL_ID,
REF_NAME,
I_ORDER,
CODE_LIST_ITEM_TYPE,
OWNER,
LAST_USER,
VERSION,
IS_CUSTOMIZABLE
-- it needs more than this
-- it needs to be associated with the correct codelist as well
)
VALUES
(
'Regulatory Contact',
'Regulatory Contact',
'ProtocolSiteTitle',
'-1',
'ProtocolSiteTitle_21',
'21',
'ProtocolSiteTitle',
'No user logged',
'No user logged',
'1',
'0'
)
END*/
GO
答案 0 :(得分:0)
我终于找到了这个问题。一段时间后,数据库从Oracle移植到SQL,并且数据库触发器中仍有一些引用未被用于移植的工具删除。