?
Solved

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

Posted on 2012-03-23
2
Medium Priority
?
1,316 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

762 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