Conditional Conditons in SQL Server

前端 未结 2 979
慢半拍i
慢半拍i 2021-01-29 07:06

I have a combobox with 3 values: All, Failed, Completed.

ALL: load All rows and no condition. Failed and

相关标签:
2条回答
  • 2021-01-29 07:33
    DECLARE @status varchar(15)
    
    --set the status
    
    SELECT * 
    FROM tbl_Location
    WHERE Status = @status OR @status = 'ALL'
    
    0 讨论(0)
  • 2021-01-29 07:51

    Make your combo-box to send a parameter call @status. Send @status = null when you need to load all row.

    Select *
    from tbl_location
    where @status is null or status = @status;
    
    0 讨论(0)
提交回复
热议问题