1

在某些情况下,我必须在存储过程中删除连字符。例如,LanguageScore 为 1 并且描述非常好。在这种情况下,我想要答案 1-Excellent。但在某些情况下,例如:LanguageScore 为 2,并且没有 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  
4

1 回答 1

0
SELECT     
    [LanguageScoreID],
     ( CASE 
           WHEN [LanguageScore]= ''
              THEN [Description]
           WHEN [Description]=''
              THEN [LanguageScore]
           ELSE [LanguageScore] + ' - ' + [Description]
       END )AS [LanguageScore] 
FROM        
    [M_LanguageScores]
于 2013-04-10T09:21:18.887 回答