设置计算列时出现问题

时间:2009-08-02 19:49:04

标签: sql-server calculated-columns string-length

我正在尝试设置此col但我收到错误:

FirstName + (CASE WHEN LEN(FirstName + LastName) > 0 THEN ' ' ELSE '') + LastName

2 个答案:

答案 0 :(得分:2)

你应该用END关闭CASE,而且我认为以下值会更好:

FirstName + (CASE WHEN LEN(FirstName) > 0 AND LEN(LastName) > 0 THEN ' ' ELSE '' END) + LastName

答案 1 :(得分:1)

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

错过了结束