I’m struggling with a case expression to determine which update statement to make. Is the below even possible or should i make separate update stored procedures for each update?
IF (SELECT pick FROM warehouse WHERE order_no = @order_no and pick = @pick) is null
CASE @pick
when 1 then
UPDATE warehouse
SET pick = @pick, startpickdate=@dchar, startpicktime=@tchar
where order_no=@order_no
when 2 then
UPDATE warehouse
SET pick = @pick, endpickdate=@dchar, endpicktime=@tchar
where order_no=@order_no
when 0 then
UPDATE warehouse
SET pick = @pick, endpickdate='', endpicktime='',startpickdate='', startpicktime=''
where order_no=@order_no
END
GO
If you want to conditionally update your columns, this approach would work for you