This seems like it should be so easy but I'm doing something wrong. I want to declare a value so that I can enter it once on top and then use it throughout my code.
A simple version of the code is below, but it doesn't work. I get no results when I run it, but if I take out the declare
and just set it manually, I get results:
declare @orderno varchar
set @orderno = '739724'
SELECT ORDSIG.* FROM ordsig
WHERE ORDER_NO = @orderno
This is what I've tried.
As said above, I get no results from the query. It should be giving me data for Order_NO
, but it does not. When I remove the Order_no = @orderno
, and set it to a constant value as Order_no = '739724'
, I get some data results.