我正在尝试提取在特定日期拨打某些号码的次数。但是,尽管在Dialed_Num列上从varchar到int添加了强制转换,我仍然收到以下错误:“ varchar值的转换溢出了int列”是否有办法限制我提取的varchar值?我以为我还是会的,因为我只希望我在Where子句中指定的两个数字
SET NOCOUNT ON
DECLARE @StartDate date = '2018-09-01', @EndDate date = '2018-09-05'
SELECT
CAST (SEGSTART as Date) as LocalDay,
CAST(Dialed_Num as INT) as DIALEDMODNUM
FROM
oauser.cmsCallHistory cms
WHERE SEGSTART BETWEEN @StartDate And @EndDate AND [Dialed_Num] IN(6582000,6752000);
答案 0 :(得分:0)
您的Dialed_Num
列需要cast
子句中的where
。
SELECT
CAST (SEGSTART as Date) as LocalDay,
CAST(Dialed_Num as INT) as DIALEDMODNUM
FROM oauser.cmsCallHistory cms
WHERE
SEGSTART BETWEEN @StartDate And @EndDate
AND
CAST(Dialed_Num as INT) IN(6582000,6752000);