on 01-29-2010 8:02 PM
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!
Russell
Hi Russell.
You don't need to use Declare.
Try this
SELECT .........
FROM .........
WHERE (T0.DocDueDate >= '[[%0]]' AND T0.DocDueDate <= '[[%1]]') AND ......
Antonio Ramos
Edited by: Antonio Ramos on Feb 17, 2010 2:38 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I will try a stored procedure / another way. Thank you -
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Russel, you can't declare variables to a SQL View.
What you can do is simply create the view without filtering the date, and the on your Select filter by the intervals you want.
Another option would be to create a Stored Procedure. You can use variables there.
Hope it helps.
Danilo Souza
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Russell Clayton,
Try to run your query to Query Generator and Save as Query Manager.
Regards,
Madhan.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.