I have a problem when the variable does not receive the select job.
The selection joins the @contracts table variable (which is used to control the loop), and then joins the actual contract and contract row tables.
my choice:
select top 1
@contract_id = c.contract_id
, @account = ch.account
, @service = cl.service
, @model = cl.model
, @serial = cl.serial
, @contract = ch.contract
from
@contracts c
inner join contractline cl on c.contract_id = cl.contract_id
inner join contractheader ch on cl.contract = ch.contract
where
cl.contract_id = @contract_id
But when I do select @contract_id, I can return NULL, like all my variables.
I did a simple select * from @contracts c inner join contractline cl on c.contract_id = cl.contract_id inner join contractheader ch on cl.contract = ch.contractone and this returns exactly 1 row with values in all the right places, without zeros in the selected values.
What did I do wrong?
source
share