views:

69

answers:

2

I am trying to set this col but I get an error:

FirstName + (CASE WHEN LEN(FirstName + LastName) > 0 THEN ' ' ELSE '') + LastName
+1  A: 
FirstName + (CASE WHEN LEN(FirstName + LastName) > 0 THEN ' ' ELSE '' end) + LastName

missing the end

cmsjr
But what if last name length was 0 ?
Wahid Bitar
I was just addressing the OP's syntax problem, not his approach.
cmsjr
+2  A: 

You should close CASE with END and also, to my opinion, the following value will be better:

FirstName + (CASE WHEN LEN(FirstName) > 0 AND LEN(LastName) > 0 THEN ' ' ELSE '' END) + LastName
Sergey Olontsev
Good point about counting the chars and sum them vs. concatenating strings which cost more performance.
Shimmy