Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Declare @StartDate/@EndDate in SQL View; cannot save (for use w/ ODBC)

I have searched all over to find out how, in proper syntax, to code a date range-specific query that works just fine in SAP, but cannot be saved in a SQL view (to in turn be linked to an Excel spreadsheet). An answer that links me to the proper thread could be nice... if it truly explains how to begin and end a functioning basic query with a user supplied date range while working in Excel.

The error I receive when starting my view with "declare" is "the Declare cursor SQL construct or statement is not supported."

Here's the beginning and abbreviated end of code from a query that works just fine without the date clause in SQL view:

DECLARE @StartDate DateTime

DECLARE @EndDate DateTime

SET @StartDate = [%0]

SET @EndDate = [%1]

SELECT .........

FROM .........

WHERE (T0.DocDueDate >= @StartDate AND T0.DocDueDate <= @EndDate) AND ......

Thank you in advance!


Former Member

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question