在某些情况下,我必须在存储过程中删除连字符。例如LanguageScore为1且Description为优秀。在这种情况下,我希望答案为1-Excellent。但是在某些情况下,例如:LanguageScore为2且没有Description for 2。那时我想要的答案是2.我该如何解决?

CREATE PROCEDURE [dbo].[p_getLanguageScores]
AS

SELECT
 [LanguageScoreID],
 [LanguageScore] + ' - ' + [Description]AS [LanguageScore]
FROM
 [M_LanguageScores]
WHERE
 [Status] > 0
ORDER BY
 [SortOrder]

SET NOCOUNT ON

最佳答案

SELECT
    [LanguageScoreID],
     ( CASE
           WHEN [LanguageScore]= ''
              THEN [Description]
           WHEN [Description]=''
              THEN [LanguageScore]
           ELSE [LanguageScore] + ' - ' + [Description]
       END )AS [LanguageScore]
FROM
    [M_LanguageScores]

10-04 19:45