# Troubleshooting Syntax Error

**URL:** <https://forums.toadworld.com/t/troubleshooting-syntax-error/37884>\
**Category:** Toad Data Point & Toad Intelligence Central\
**Created:** [June 20, 2016, 9:52am UTC](https://forums.toadworld.com/t/troubleshooting-syntax-error/37884 "2016-06-20T09:52:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlegrand](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@jlegrand](https://forums.toadworld.com/u/jlegrand)\
**Post date:** [June 20, 2016, 9:52am UTC](https://forums.toadworld.com/t/troubleshooting-syntax-error/37884/1 "2016-06-20T09:52:54Z")

</div>

Hi all,

I’m receiving the following error when attempting to automate a .tim import template

Steps taken:

1. Wrote and tested SQL query against data source, it works

2. Created an import template to query one database (Teradata database) and import the results into a SQL Server database. When I choose to run the import now, it works totally fine.

3. When I choose to send to automation (or create a new automation script and use the import wizard to load up the .tim file that I created in step 2), the automation run fails with the following error:

Import\_Activity - [Teradata][ODBC Teradata Driver][Teradata Database] Syntax error, expected something like an ‘EXCEPT’ keyword or an ‘UNION’ keyword or a ‘MINUS’ keyword between ‘)’ and ‘;’. (“Embedded Query” into “[Clarity - Tapestry].dbo.WFP\_PRODUCTION”)

To reiterate: the sql that drives the import step works in TOAD Data Point when I run from the sql editor, the import .tim works when I run it manually. However, it does not work when run via automation.

---

<div class="post-metadata">

**Author:** ![Petr.Hodovsky](https://avatars.discourse-cdn.com/v4/letter/p/f0a364/32.png) [@Petr.Hodovsky](https://forums.toadworld.com/u/Petr.Hodovsky)\
**Post date:** [June 21, 2016, 5:09am UTC](https://forums.toadworld.com/t/troubleshooting-syntax-error/37884/2 "2016-06-21T05:09:07Z")

</div>

Hi jlegrand, I could not reproduce your problem with my SQL. Can you send me example of your SQL query? Please try checking your connection settings in the automation script and try removing any comments from your SQL query. Regards, Petr

---

<div class="post-metadata">

**Author:** ![GregDavis11009](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/gregdavis11009/32/122_2.png) [@GregDavis11009](https://forums.toadworld.com/u/GregDavis11009)\
**Post date:** [June 21, 2016, 9:42am UTC](https://forums.toadworld.com/t/troubleshooting-syntax-error/37884/3 "2016-06-21T09:42:16Z")

</div>

Try taking the semicolon out. Should work without it. Try to make the import SQL just the select for the import and not multiple commands followed by a select if you can. If you need to set things up before running the import try to do that in a separate job step that executes the other sql before running the import step.

---

<div class="post-metadata">

**Author:** ![jlegrand](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@jlegrand](https://forums.toadworld.com/u/jlegrand)\
**Post date:** [June 21, 2016, 12:29pm UTC](https://forums.toadworld.com/t/troubleshooting-syntax-error/37884/4 "2016-06-21T12:29:22Z")

</div>

Here’s the code. I’ve removed company specific segments, have run this against toad, and still receive the same error.

Note: the code works when run from sql editor. When I create the import statement and choose “import data now” it works. Once the .tim is saved and I load it into an automation script, the script itself fails.

select

ap.status\_date **as** PROD\_DT

,‘HI’ **as** REGION

, **case**

**when** ven.vendor\_name **like** ‘%Hawaii%’ **then** ‘Internal’

**else** ‘External’

**end**  **as** INT\_EXT

,lob.lob\_name **as** LOB

, **case**  **when** ap.orig\_adjst\_clm\_id **is**  **null**  **and** ap.orig\_rev\_clm\_id **is**  **null**  **then** ‘Y’ **else** ‘N’ **end**  **as** FIRST\_PASS

, **case**  **when** d\_aa.claim\_id **is**  **not**  **null**  **then** ‘Y’ **else** ‘N’ **end**  **as** AA

,count ( **distinct** clm.internal\_id) **as** CLM\_CT

**from** ap\_claim ap

**inner**  **join** clm\_map clm **on** ap.claim\_id = clm.cid

**left**  **outer**  **join** clarity\_vendor ven **on** ap.vendor\_id = ven.vendor\_id

**left**  **outer**  **join** clarity\_lob lob **on** ap.clm\_lob\_id = lob.lob\_id

**left**  **outer**  **join**

( **SELECT**  **distinct** CLM.CLAIM\_ID

**FROM** AP\_CLAIM CLM

**WHERE** CLM.CLAIM\_ID **NOT**  **IN**

( **SELECT** CLAIM\_ID

**FROM** AP\_CLAIM\_CHANGE\_HX

**WHERE** (

(ACTION\_C = ‘18100’ **AND** CHANGE\_HX\_NEW\_VAL = ‘2’)

**OR** CHANGE\_HX\_USER\_ID **NOT**  **IN** (‘130HI50101’,‘130HI50100’)))

**AND** (CLM.STATUS\_C **IN** (‘3’,‘4’) **AND** CLM.ORIG\_REV\_CLM\_ID **IS**  **NULL**  **AND** CLM.ORIG\_ADJST\_CLM\_ID **IS**  **NULL** )

) D\_AA **on** ap.claim\_id = d\_aa.claim\_id

where

ap.status\_c **in** (3,4,5)

**group**  **by** 1,2,3,4,5,6

---

<div class="post-metadata">

**Author:** ![GregDavis11009](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/gregdavis11009/32/122_2.png) [@GregDavis11009](https://forums.toadworld.com/u/GregDavis11009)\
**Post date:** [June 21, 2016, 5:22pm UTC](https://forums.toadworld.com/t/troubleshooting-syntax-error/37884/5 "2016-06-21T17:22:44Z")

</div>

I don’t see anything wrong with your sql and there is no semicolon in it, so the error message does not make sense. It might be something specific to a Terradata connection that automation is not handling correctly. You need Toad support analyst to weigh in on this one. I have never used a Terradata connection.

---

<div class="post-metadata">

**Author:** ![clorence](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/clorence/32/326_2.png) [@clorence](https://forums.toadworld.com/u/clorence)\
**Post date:** [June 22, 2016, 8:25am UTC](https://forums.toadworld.com/t/troubleshooting-syntax-error/37884/6 "2016-06-22T08:25:17Z")

</div>

I just noticed that the Toad editor no longer likes blank rows within SQL statements. Try removing all of the blank rows in your SQL.

Does anyone know if this is a setting somewhere? Not allowing blank rows is very annoying…

**For example:**

Select \*  
From tableABC; – Works great

But…

Select \*

From tblABC; – Throws a syntax error

---

<div class="post-metadata">

**Author:** ![Debbie\_Peabody](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/debbie_peabody/32/18_2.png) [@Debbie\_Peabody](https://forums.toadworld.com/u/Debbie_Peabody)\
**Post date:** [June 24, 2016, 6:22pm UTC](https://forums.toadworld.com/t/troubleshooting-syntax-error/37884/7 "2016-06-24T18:22:01Z")

</div>

I would like to try and reproduce this exact error. Can you take the SQL above and execute in the editor? After that generate a support bundle and add here as attachment.

In our later releases of TDP, if you have SQL Editor focused when generating support bundle we will create ddl for the columns used in the SQL. It puts it in the SQLAnalyze.log file in the app dir,

If you can get me that file generated I can reproduce the error.
