0
我莫名其妙地堅持這一錯誤消息,我的痘痘查詢中SQL唯一標識符是浮動
消息206,級別16,狀態2不兼容的37行 操作數類型衝突:唯一標識符是浮動不兼容
我已經嘗試設置uniqueidentifier的值是唯一標識符在他們的表中
或者將值設置爲0以進一步確定問題,但我沒有運氣。
USE [master];
if OBJECT_ID('tempdb.dbo.powerdeviation') is not null
BEGIN
DROP TABLE tempdb.dbo.powerdeviation
END
DECLARE @factor decimal = '1,5' /* delete VALUE in workflow */
DECLARE @item nvarchar(256) = '450294' /*delete Value in workflow */
DECLARE @item2 nvarchar(256) = '450295' /*delete Value in workflow */
CREATE TABLE tempdb.dbo.powerdeviation(
DeviceName nvarchar(256),
DeviceTypeName nvarchar(256),
TableID varchar(50),
SiteLocation varchar(50),
SiteName varchar(50),
DeviceID uniqueidentifier,
DeviceSerial nvarchar(256),
TableName nvarchar(256),
Factor decimal,
tPowerColumn varchar(50),
tPower float,
t2DeviceSerial varchar(50),
t2DeviceID float,
t2PowerColumn varchar(50),
t2Power float,
t2Powerdeviation float,
SitePower float,
SitePowerDeviation float,
typePower float,
typePowerDeviation float
);
With cteTurbine1 as
( SELECT D.Name as Devicename, DT.Name as Devicetypename, LD.ID as TableID, S.Location, S.Name AS LocationName, D.ID AS DeviceID, D.SerialNumber AS DeviceSerial, LD.Name AS TableName, LC.Name AS PowerColumn
FROM CompMainConfig.dbo.DeviceType DT
JOIN CompMainConfig.dbo.Device D ON DT.ID = D.DeviceTypeID
JOIN CompMainConfig.dbo.LogTableDefinition LD ON LD.ID = DT.LogTableID
JOIN CompMainConfig.dbo.Site S ON D.SiteID = S.ID
JOIN CompMainConfig.dbo.LogColumnDefinition LC ON LC.TableID = DT.LogTableID
JOIN CompMainConfig..Resource R ON LC.LocalizedNameID = R.ResourceID
WHERE D.SerialNumber = (@item) and R.CultureName = 'en' and LC.MeasureFamily = '1' and LC.MeasureType = '1' and LC.OrdinalIndex = '0'
),
cteTurbine2 as
( SELECT D.Name as Devicename, DT.Name as Devicetypename, LD.ID as TableID, S.Location, S.Name AS LocationName, D.ID AS DeviceID, D.SerialNumber AS DeviceSerial, LD.Name AS TableName, LC.Name AS PowerColumn
FROM CompMainConfig.dbo.Device D
JOIN CompMainConfig.dbo.DeviceType DT ON D.DeviceTypeID = DT.ID
JOIN CompMainConfig.dbo.LogTableDefinition LD ON LD.ID = DT.LogTableID
JOIN CompMainConfig.dbo.Site S ON D.SiteID = S.ID
JOIN CompMainConfig.dbo.LogColumnDefinition LC ON LC.TableID = DT.LogTableID
JOIN CompMainConfig..Resource R ON LC.LocalizedNameID = R.ResourceID
WHERE D.SerialNumber = (@item) and R.CultureName = 'en' and LC.MeasureFamily = '1' and LC.MeasureType = '1' and LC.OrdinalIndex = '0'
)
INSERT INTO tempdb.dbo.powerdeviation
SELECT cteTurbine1.Devicename, cteTurbine1.Devicetypename, cteTurbine1.TableID, cteTurbine1.Location, cteTurbine1.LocationName, cteTurbine1.DeviceID, cteTurbine1.DeviceSerial, cteTurbine1.TableName, @factor, cteTurbine1.PowerColumn,0, cteturbine2.DeviceSerial ,cteturbine2.DeviceID, cteTurbine2.PowerColumn, 0,0,0,0,0,0
FROM cteturbine1, cteturbine2
Option2正在工作,謝謝。 – veritaS