校验和在程序中返回null。而且当我尝试只执行查询时..我得到
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'Audit C recorded' to data type tinyint.
..你能帮我吗?
SELECT CAST(ABS(CHECKSUM(Indicator)) % 450 AS TINYINT) AS Indicator,
CAST(CIndicator AS VARCHAR(100)) AS CIndicator,
CAST(SK_IndicatorL2 AS TINYINT) AS SK_IndicatorL2,
CAST(ABS(CHECKSUM(IndicatorL2)) % 450 AS TINYINT) AS IndicatorL2
FROM ( VALUES ('Alcohol',
'Alcohol',
'Audit C recorded',
'Audit C recorded (excluding screen in 3y prior to start of quarter)'),
('Alcohol',
'Alcohol',
'Community Detox and TH CAT',
'Community Detox and TH CAT'),
('Alcohol',
'Alcohol',
'Follow Up appointment',
'Follow Up appointment'),
('Healthy Lifestyles',
'Healthy Lifestyles',
'HealthyLifestyle-Aged 19-39',
'HealthyLifestyle-Aged 19-39'),
('Healthy Lifestyles',
'Healthy Lifestyles',
'Aged 19-39 - BMI recorded',
'Aged 19-39 - BMI recorded') ) AS Nis (Indicator,
CIndicator,
SK_IndicatorL2,
IndicatorL2)
我试过这样做: SELECT CAST(ABS(CHECKSUM('Audit Crecorded')) % 250 as TinyInt) 我得到一个正确的整数值。