如何更改存储过程中SELECT返回的值?

时间:2014-07-25 05:17:41

标签: sql-server

我的存储过程返回以下内容:

    DECLARE @AnswerGridCorrect VARCHAR(20)
    ...
    ...
    SELECT  @AnswerGridResponses AS AnswerGridResponses,
            @AnswerGridCorrect AS AnswerGridCorrect,
            @Authenticated As Authenticated,
            @RC AS RC,
            @Result AS Result

如果NULL,如何让@AnswerGridCorrect@Result = 'F'

1 个答案:

答案 0 :(得分:1)

描述

您可以使用switch case语句执行此操作。

示例

DECLARE @AnswerGridCorrect VARCHAR(20)
...
...
SELECT  @AnswerGridResponses AS AnswerGridResponses,
        CASE @Result
           WHEN 'F' THEN null
           ELSE @AnswerGridCorrect 
        END AS AnswerGridCorrect,
        @Authenticated As Authenticated,
        @RC AS RC,
        @Result AS Result

更多信息