0

我在为 SSIS 转换修剪连接键时遇到了一些麻烦。

SELECT year_time, substring(rtrim(cast(region_code+county_code+district_code as varchar(100)), 5,4)as DR, rtrim(ltrim(T1.district_name)) as 'DNR', SUM(CAST(K12 AS INT)) AS 'TR'   
FROM Database_Table
GROUP BY year_time, region_code+county_code+district_code, district_name
order by year_time, district_code_raw, district_name_raw

我收到一个错误,我的 rtrim 函数需要 1 个参数。我相信错误是在串联上。

4

1 回答 1

1

您缺少括号来关闭RTRIM()

SELECT year_time, 
    substring(rtrim(cast(region_code+county_code+district_code as varchar(100))), 5,4)as DR, 
    rtrim(ltrim(T1.district_name)) as 'DNR',                                 --^--missing
    SUM(CAST(K12 AS INT)) AS 'TR'   
FROM Database_Table
GROUP BY year_time, region_code+county_code+district_code, district_name
order by year_time, district_code_raw, district_name_raw
于 2013-04-01T16:44:10.903 回答