1
我在將測試數據插入表中時遇到問題。我收到標題中列出的錯誤。沒有找到解決方法,我做了很多搜索。錯誤SQL72014:將varchar值轉換爲數據類型int時轉換失敗
在Visual Studio 2012解決方案中,我有幾個項目,其中之一是一個數據庫項目。我正在定義幾個表格。有問題的一個是:
CREATE TABLE [dbo].[tblKppHierarchyPcl]
(
[ID] NUMERIC(18,0) NOT NULL,
[Name] VARCHAR(500),
[PartStructureKey] NUMERIC(18,0) NOT NULL,
[PartNumber] VARCHAR(500) NOT NULL,
[ParentPartNumber] VARCHAR(500) NULL,
[TargetCost] DECIMAL(30,4) NULL,
[UnitCost] DECIMAL(30,4) NULL,
[CostMaturityID] INT NULL,
[Ratio] DECIMAL(16,2) NULL,
[Contribution] DECIMAL(16,2) NULL,
[ChildPartTargetWeight] NUMERIC(18,2) NULL,
[ChildPartWeight] NUMERIC(18,2) NULL,
CONSTRAINT [FK_tblKppHierarchyPcl_tblCostMaturity] FOREIGN KEY (CostMaturityID)
REFERENCES tblCostMaturity([CostMaturityID])
)
使用Script.PostDeployment1.sql文件,我想用測試數據來填充表所示:
INSERT INTO [dbo].[tblKppHierarchyPcl]
([ID]
,[Name]
,[PartStructureKey]
,[PartNumber]
,[ParentPartNumber]
,[TargetCost]
,[UnitCost]
,[CostMaturityID]
,[Ratio]
,[Contribution]
,[ChildPartTargetWeight]
,[ChildPartWeight]) VALUES
(61090,'Coolant Quick Disconnect',125216,'FS-252-6FO','H432677DB-1',27.03,70.61,2,2.61,0.01,0,NULL)
我試圖將數據推到數據庫通過SqlPublish。
我的問題是這樣的:當部署後腳本試圖插入數據,我得到以下錯誤:
Error SQL72014: .Net SqlClient Data Provider: Msg 245, Level 16, State 1, Line 76 Conversion
failed when converting the varchar value 'Coolant Quick Disconnect' to data type int.
所以它具有與插入「冷卻液快速斷開」入名稱列問題。名稱列是CLEARLY一個varchar列,但不知何故它認爲它是一個int列。
任何想法?
編輯:我正在使用SQL Server 2012.此表上沒有觸發器。
什麼版本的SQL Server?,你有那個表上的觸發器? – Lamak
請參閱上面的註釋。沒有觸發器。 – sshirley
那麼,我沒有看到錯誤在哪裏,它適用於[sqlfiddle](http://sqlfiddle.com/#!6/e694b)(如果我把參考出來) – Lamak