• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7195
  • Last Modified:

How to create SQL expression fields in Crystal Reports ?

Hi,

I have had a problem with creating SQL expression fields in CR.

I have always catched the error "Syntax error found in the statement" when trying to edit any SQL statement in the SQL Expression Editor(Crystal Reports), even it was a very simple one and copied/parsed from the Crystal SQL Designer which had executed it well, for example:
-----------
SELECT
  Employee.`First Name`
FROM
 `Employee` Employee
-----------

I wonder if the error actually resulted from the syntax or other reasons ?

I am expecting the answer from all of you who is interested in.

Thanks in advance !

VietTrung.  

0
VietTrung
Asked:
VietTrung
2 Solutions
 
mlmccCommented:

SELECT
 Employee.`First Name`
FROM
`Employee` Employee

Do you get an error in that statement?

I don't see anything obviously wrong.

What database are you running against?

MS SQL Server would require it as

SELECT
 Employee.[First Name]
FROM
[Employee] Employee

mlmcc



0
 
mbrown212Commented:
Crystal doesn't recognize normal SQL very well. It's really, really picky.

SELECT
    "TABLE_NAME"."FIELD_NAME",
    "TABLE_NAME"."FIELDNAME
FROM
    "SCHEMA"."TABLE_NAME" "ALIAS"
WHERE
    "TABLE_NAME"."FIELD_NAME" = "TABLE_NAME"."FIELD_NAME"

You can do union queries and substrings and use functions, but it's almost painful.
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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now