[Teradata Database] [3706] Syntax error: expected something between the word 'groupdn' and ','.

Database
Enthusiast

[Teradata Database] [3706] Syntax error: expected something between the word 'groupdn' and ','.

Hello - I am trying to run the query below and keep getting hit with the following error message:

[Teradata Database] [3706] Syntax error: expected something between the word 'groupdn' and ','.

 

Select g.name as grpName,Substring(g.groupdn,1,Charindex(',', g.groupdn)-1) as Node1,g.as_of_time as AsOf_time

from ad_Group_6 g

where g.as_of_time='2017-01-24 00:00:00'

and g.groupdn like '%DC=abc%'

group by g.groupdn,g.name, g.as_of_tms

order by 2

 

I've done research and it was suggested in several posts that each field in the SELECT statement needs an alias, but this has not solved my issue.  Why am I receiving this error message still?


Accepted Solutions
Senior Apprentice

Re: [Teradata Database] [3706] Syntax error: expected something between the word 'groupdn' and ','.

This is MS SQL Server syntax, in Teradata there's no CHARINDEX and the SUBSTRING syntax is different:

Substring(g.groupdn from 1 for position (',' in g.groupdn)-1) -- Standard SQL 

or 

Substr(g.groupdn, 1, position (',' in g.groupdn)-1) -- Teradata SQL

Shortest/easiest:

STRTOK(g.groupdn, ',', 1)

 

1 ACCEPTED SOLUTION
3 REPLIES
Senior Apprentice

Re: [Teradata Database] [3706] Syntax error: expected something between the word 'groupdn' and ','.

This is MS SQL Server syntax, in Teradata there's no CHARINDEX and the SUBSTRING syntax is different:

Substring(g.groupdn from 1 for position (',' in g.groupdn)-1) -- Standard SQL 

or 

Substr(g.groupdn, 1, position (',' in g.groupdn)-1) -- Teradata SQL

Shortest/easiest:

STRTOK(g.groupdn, ',', 1)

 

Teradata Employee

Re: [Teradata Database] [3706] Syntax error: expected something between the word 'groupdn' and ','.

Mixing Teradata and ANSI syntax.

Either:

SUBSTRING( string-expr FROM expr FOR expr)

or

SUBSTR(string-expr, expr, expr)

Enthusiast

Re: [Teradata Database] [3706] Syntax error: expected something between the word 'groupdn' and ','.

Hi dnoeth,

 

All of your solutions are valid, but I absolutely love the 'easiest' one:

 

STRTOK(g.groupdn, ',', 1)

 

Being a Microsoft T-SQL guy, I've never encountered this function before - amazing and efficient!