0

この構文が不正な理由を理解しようとしていますが、そうではありません。

update Entry
set Name =  Case charindex('/', reverse(Name))
                when charindex('/', reverse(Name)) > 0 then right(Name, charindex('/', reverse(Name)) -1)
                when charindex('/', reverse(Name)) < 0 then Name
            End
4

1 に答える 1

2

これを試して:

update Entry 
set Name =  Case 
                when charindex('/', reverse(Name)) > 0 then right(Name, charindex('/', reverse(Name)) -1) 
                when charindex('/', reverse(Name)) < 0 then Name 
            End 

編集:またはこれ:

update Entry 
set Name =  Case SIGN(charindex('/', reverse(Name)) )
                when 1 then right(Name, charindex('/', reverse(Name)) -1) 
                when -1 then Name 
            End 

WHEN の前に式がある CASE は、その式を WHEN に続く各式と比較し、一致が見つかるまで順番に比較します。CASE の直後に WHEN を指定すると、TRUE と評価される式が見つかるまで、WHEN に続く各式がチェックされます。最初の使用法では、式は比較可能でなければなりません。2 番目では、式は T/F に評価される必要があります。

于 2012-06-15T20:48:47.737 に答える