這實際上適用於之前的問題,TSQL 2008 USING LTRIM(RTRIM and Still Have SpacesTSQL CASE WHEN那麼syntax - 使用更換
我在寫使用OMG小馬語句刪除非空非可見字符一個非常漫長的SELECT語句的點
(WHEN PropStreetAddr is NOT NULL THEN
(SELECT LTRIM(RTRIM((REPLACE(PropStreetAddr,
SUBSTRING(PropStreetAddr,
PATINDEX('%[^a-zA-Z0-9 '''''']%',
PropStreetAddr),
1), '') AS PropStreetAddr)
查詢:
SELECT
CASE WHEN LOAN_NUMBER IS NOT NULL THEN
REPLACE(LOAN_NUMBER,SUBSTRING (LOAN_NUMBER,PATINDEX(' %[^a-zA-Z0-9 '''''']% ' , ' ') as LOAN_NUMBER.
,CASE WHEN MERS_ID IS NOT NULL THEN
REPLACE( MERS_ID,SUBSTRING (MERS_ID,PATINDEX(' %[^a-zA-Z0-9 '''''']% ' , ' ') as MERS_ID
...127 more lines of similar statements
當我檢查語法我收到此錯誤指向第一個case語句SELECT後:
Msg 156,Level 15,State 1,Line 143 關鍵字'as'附近的語法不正確。
有人可以幫助我瞭解我失蹤了嗎?
+1 ...和REPLACE(SUBSTRING(PATINDEX(目前沒有邏輯意義)... – Tahbaza 2010-08-02 23:20:44
OMG,我一直在看這個代碼太長了!我感謝您的意見和擡起頭來..這裏是什麼看到我需要解決這個問題..所以非常抱歉,我錯過了這個更早... 選擇案例當LOAN_NUMBER不是NULL然後替換(LOAN_NUMBER,SUBSTRING(LOAN_NUMBER,PATINDEX('%[^ a-zA-Z0-9 '''''']%',LOAN_NUMBER),1),'')以LOAN_NUMBER結尾等等 – JMS49 2010-08-02 23:27:56