0

I'm trying to set salesorders.pickinglocation to 448 if my salesorder is 68 and salesorderprexies are not 'SO-' OR 'QU-'. Im getting a sytax error .

DECLARE @SalesOrder bigint = 68       --[Identifier]  
DECLARE @PickingLocation bigint  = 448

set SalesOrders.PickingLocation = @PickingLocation

FROM SalesOrderItems
inner join salesorders on salesorderitems.salesorder = SalesOrders.SalesOrder
inner join SalesOrderPrefixes on salesorders.salesorderprefix = SalesOrderPrefixes.salesorderprefix

WHERE SalesOrders.Salesorder = @SalesOrder
AND SalesOrderPrefixes.SalesOrderPrefixId <>'SO-' AND SalesOrderPrefixes.SalesOrderPrefixId <> 'QU-'
Greg
  • 476
  • 9
  • 23
  • Ahh yeah I didn't know about that. Is there any way i can do the OR an easier way? – Greg Nov 07 '18 at 11:48
  • 3
    To exclude both you want AND not OR & you are missing an UPDATE clause - https://stackoverflow.com/questions/1604091/update-a-table-using-join-in-sql-server – Alex K. Nov 07 '18 at 11:49
  • Cheers Alex K ;) – Greg Nov 07 '18 at 11:50
  • To make the where condition more readable you can try SalesOrderPrefixes.SalesOrderPrefixID NOT IN('SO-','QU-') – Matthew Baker Nov 07 '18 at 11:51
  • In general using the IN command is not very efficient, especially as the number of values increase. However compared to hard coding each condition I believe its comparable. – Matthew Baker Nov 07 '18 at 11:54
  • As @AlexK. already said: You are probably missing an `UPDATE SalesOrderItems` before your `set...` – Ocaso Protal Nov 07 '18 at 13:07

0 Answers0