2013-04-01 93 views
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個參數。我相信錯誤在串聯。

+2

您是否收到錯誤?有什麼麻煩? – Taryn

+0

我不知道你的問題在這裏。你沒有問過,也沒有說出什麼麻煩...... –

+1

rtrim函數需要1個參數 – Tone

回答

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 
+0

謝謝。我盯着這個,需要額外的眼睛來解決這個簡單的錯誤。 – Tone

+1

@Tone每當你得到這樣的東西時,你總是可以格式化代碼來查看開始/結束括號。 – Taryn