sql 条件处理

DECLARE @Service_Id INT

SET @Service_Id = 2

SELECT TOP 1000 service_id,* FROM dbo.MgtRpt_Inspected_Order

WHERE 1=1

AND CASE WHEN @Service_Id=-1 THEN -1 ELSE Service_Id END = @Service_Id

ORDER BY tran_ser_id DESC

posted @ 2010-12-13 12:30  Benny Ng  阅读(141)  评论(0编辑  收藏  举报