Avatar of Star79
Star79
Flag for United States of America

asked on 

Case Statement in Where Clause on a Parameter

Hello I have the below store proc
declare @po_start_date varchar(15)
declare @po_end_date varchar(15)

SELECT
     ex.vendor_code,
     ex.program,
     ex.Po_num,
     ex.date_create,
     ex.Printed_Date,
     ex.status,
     ex.po_item_No,
     ex.Supplier_pn,
     ex.price,
     ex.unit_of_meas,
     ex.extd_cost,
     ex.quantity,
     ex.open_qty,
     ex.baseline_date,
     ex.[Current_Date],
     ex.nomenclature,
     ex.customer_no,
     ex.control_and_item,
     ex.need_date,
     ex.fax,
     ex.state,
     ex.vendor_name,
     ex.vendor_phone,
     ex.vendor_contact,
     ex.disposition,
     ex.ship_via,
     ex.need_date3,
     ex.a_status,
     ex.data,
     ex.next_higher_assy

FROM
     expeditetbl1 ex 
     left join
(
    select 
        emp_num, pGM_CODES 
    from  exp_dummytbl
    group by emp_num, pGM_CODES
) 
Q ON ex.program = Q.pGM_CODES

where  Q.emp_num='092'
     and ex.vendor_code IS NOT null
     and ex.open_qty <> 0
     and (ex.program ='632'
     and Case  
		When @po_start_date <> ''
	    Then (ex.[Current_Date] > = @po_start_date)
		END 

Open in new window


Iam trying to put a case condition on the param start date to check to see if its empty string or the user has passed a value.Iam getting an incorrect syntax on my code.Please help.
Microsoft SQL Server 2005MySQL ServerMicrosoft SQL Server 2008

Avatar of undefined
Last Comment
HainKurt

8/22/2022 - Mon