Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2012-03-23
2
Medium Priority
?
1,366 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:kkbenj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 total points
ID: 37758822
This doesn't look right:

Delete from lookuptablevalues ltv
where ltv.keyvalue in


Should be:

Delete from ltv
where ltv.keyvalue in

 Not sure how you get away with it in the query window...

Jim.
0
 

Author Comment

by:kkbenj
ID: 37759050
The table name is lookuptablevalues, ltv being the abbreviation.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question