我有这样的大 SQL 查询:
Select Distinct [Student].[Class].roll_nbr as [PERIOD-NBR],[Student].[Class].ent_nbr as [CLASS-NBR],
IsNull(Stuff((SELECT CAST(', ' AS Varchar(MAX)) + CAST([Student].[Subject].ent_nbr AS Varchar(MAX))
FROM [Student].[Subject]
WHERE [Student].[Subject].roll_nbr = [Student].[Class].roll_nbr
and ([Student].[Subject].class_nbr = [Student].[Class].roll_assignment_nbr
or ([Student].[Class].roll_assignment_nbr = '0'
and [Student].[Subject].class_nbr = [Student].[School].bus_stop) )
AND [Student].[Subject].ent_nbr <> ''
FOR XML PATH ('')), 1, 2, ''), '')
AS [OLD-STUDENT-NBR.OLD],IsNull(Stuff((SELECT CAST(', ' AS Varchar(MAX)) + ....
它继续下去,一个页面长的查询,它构建了一个报告。我遇到的问题是一些变量出现错误消息:
Error converting data type varchar to numeric.
这是非常通用的错误,没有告诉我是哪个变量。有什么方法可以查明 sql 2008 中哪个变量出错了?