2012-08-27 53 views

回答

23
update tableA 
set first_name = case when first_name is null then null else 'aaa' end, 
last_name = case when last_name is null then null else 'bbb' end, 
... 
+4

或'當FIRST_NAME不爲空,然後「AAA」 end'因爲有未處理的情況下,一個隱含的'否則null'情況。 –

1

只是另一種方法更簡潔一些(少可讀性):

UPDATE TableA 
SET first_name = left( 'AAA' + first_name, 3) , 
    last_name = left( 'BBB' + last_name, 3) , 
    address1 = left( '123' + address1, 3) , 
    address2 = left( 'Fake St.,' + address2, len('Fake St.,')) , 
    ...