Link to home
Start Free TrialLog in
Avatar of kkbenj
kkbenj

asked on

SQLSTATE 42000 (Error 102) Incorrect syntax near 'ltv'

I'm new to SQL Server Agent and set up a job to run a query string that runs successfully in the query window.

It is a Transact-SQL script (T-SQL) type.

Delete from lookuptablevalues ltv
where ltv.keyvalue in
(
select distinct(si.value_ci) collate Latin1_General_CI_AS keyvalue
from recipientlists rl, recipientstringvalues rsv, rv_stringindex si, lookuptablevalues ltv,
recipientdatevalues rdv
where
    rsv.recipientid = rl.recipientid
and rl.recipientid = rdv.recipientid
and rsv.fieldid = 1462
and rl.listid=5773
and si.id = rsv.valueid
and ltv.lookupid=193
and ltv.keyvalue = si.value_ci collate Latin1_General_CS_AS
and rdv.value < getdate()-7
)

Open in new window


Can someone kindly educate to as to what is wrong?  Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kkbenj
kkbenj

ASKER

The table name is lookuptablevalues, ltv being the abbreviation.