[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Incorrect syntax near 'datetime'

Posted on 2011-04-27
13
Medium Priority
?
1,016 Views
Last Modified: 2012-05-11
Hello:

In attempting to generate a SQL 2008 report with date/time parameters, I get the following error:

Query execution failed for dataset 'DocDate'
Incorrect syntax near 'datetime'

Sigh....SQL 2005 was much easier to compose reports in.  

OK....what do I do?  Or, what information do you need to help me.

Apitech
0
Comment
Question by:apitech
  • 7
  • 3
  • 3
13 Comments
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 35475555
need query.
0
 
LVL 1

Author Comment

by:apitech
ID: 35475608
Hello:

Below is the query of DataSet1 and DocDate, respectively:

SELECT SOP30200.SOPTYPE, SOP30200.SOPNUMBE, SOP30200.CUSTNMBR, SOP30300.ITEMNMBR,
SOP30300.XTNDPRCE, SOP30300.QUANTITY, SOP30300.SALSTERR, SOP30300.SLPRSNID,
IV00101.ITMCLSCD, SOP30200.VOIDSTTS, SOP30200.DOCDATE, IV00101.USCATVLS_5,
SOP30300.UOFM
 FROM   (KLAI.dbo.SOP30200 INNER JOIN KLAI.dbo.SOP30300
ON (SOP30200.SOPTYPE=SOP30300.SOPTYPE) AND (SOP30200.SOPNUMBE=SOP30300.SOPNUMBE))
INNER JOIN KLAI.dbo.IV00101 ON SOP30300.ITEMNMBR=IV00101.ITEMNMBR
 WHERE  (SOP30200.SOPTYPE=3 OR SOP30200.SOPTYPE=4) AND SOP30200.VOIDSTTS=0
AND (SOP30300.SALSTERR>='REGION 1' AND SOP30300.SALSTERR<='REGION 99')
AND (DocDate BETWEEN @StartDate and @EndDate)


select DISTINCT DOCDATE from SOP30200
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 35475729
SELECT SOP30200.SOPTYPE, SOP30200.SOPNUMBE, SOP30200.CUSTNMBR, SOP30300.ITEMNMBR,
SOP30300.XTNDPRCE, SOP30300.QUANTITY, SOP30300.SALSTERR, SOP30300.SLPRSNID,
IV00101.ITMCLSCD, SOP30200.VOIDSTTS, SOP30200.DOCDATE, IV00101.USCATVLS_5,
SOP30300.UOFM
 FROM  KLAI.dbo.SOP30200
      INNER JOIN KLAI.dbo.SOP30300
      ON SOP30200.SOPTYPE=SOP30300.SOPTYPE AND SOP30200.SOPNUMBE=SOP30300.SOPNUMBE
      INNER JOIN KLAI.dbo.IV00101
      ON SOP30300.ITEMNMBR=IV00101.ITEMNMBR
 WHERE  (SOP30200.SOPTYPE=3 OR SOP30200.SOPTYPE=4) AND SOP30200.VOIDSTTS=0
      AND SOP30300.SALSTERR>='REGION 1' AND SOP30300.SALSTERR<='REGION 99'
AND (DocDate BETWEEN @StartDate and @EndDate)
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:apitech
ID: 35475830
What did you change?  I'm unclear.
0
 
LVL 1

Author Comment

by:apitech
ID: 35475889
I think you may have misunderstood.  The queries that I pasted above were two separate queries for two separate datasets.  I need that second query.  At least, that's what SQL 2005 used to twist your arm to do when you ever wanted to do a simple filter.  (Crystal Reports is so much easier!)

Otherwise, the only change that I can see that you made is that you took parentheses out.  I did the same thing and got the same error.

HELP!
0
 
LVL 1

Author Comment

by:apitech
ID: 35476691
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????/
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 35481000
select DISTINCT DOCDATE from SOP30200

To which field you are filtering. Please check the datatype of parameter and the fields to which you are applying filter.
0
 
LVL 22

Expert Comment

by:Nico Bontenbal
ID: 35481368
Could you upload your .rdl file (as .xml) along with the create table statements of the tables used by the queries for the report?
0
 
LVL 1

Author Comment

by:apitech
ID: 35482657
PatelAlpesh:  That DOCDATE statement is the dataset for the start and end date parameters!  We need that, of course.

Nicobo:  I can't upload the create table statements.  Those tables are homegrown tables created by Microsoft Dynamics and not by me.  I will try to upload the rdl, ASAP.
0
 
LVL 22

Expert Comment

by:Nico Bontenbal
ID: 35482766
<<I can't upload the create table statements.>>
Maybe you can use this technique:
http://www.gp-dynamics.com/dynamics-gp-command-details.asp?id=40
But first lets see if we can solve this one with only the .rdl.
0
 
LVL 1

Author Comment

by:apitech
ID: 35487579
Hi There, Nicobo:

Attached is the rdl.  Please let me know, if you for sure need those statements!

Thank you, so much, for going the extra mile for me on all of this stuff!  You truly are a bright "star" here on Experts Exchange!

Apitech
Summary-Sales-By-Product.xml
0
 
LVL 22

Accepted Solution

by:
Nico Bontenbal earned 2000 total points
ID: 35489441
After creating the tables (based on the fieldnames in the query) I got a different error "Ambiguous column name 'docdate'". I rosolved this by changing the last line of the query to:
AND (SOP30200.DocDate BETWEEN @StartDate and @EndDate)
After this change I was able to run the report without any errors.
0
 
LVL 1

Author Comment

by:apitech
ID: 35490406
Thank you, Nicobo!  That worked!

You truly are a Master!

Apitech
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Steps to solve SSRS SQL 2008 R2 User Access Control (UAC) Permission Error With the introduction of SQL Server 2008 R2 and Vista (Windows 7 as well) came new enhanced security features. One of the features included was User Access Control (UAC) t…
Introduction Earlier I wrote an article about the new lookup functions (http://www.experts-exchange.com/A_3433.html) that ship with SQL Server 2008 R2.  In this article I’m going to show you another new feature of SSRS 2008 R2, this time in the vis…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…

591 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