Stepping through the Report Wizard to create a new report, the second step
"Design the Query" I entered my SP name. When I click next I get the
following error.
"There is an error in the query. Line 1: Incorrect syntax near
'STORED_PROCEDURE_NAME""
I ran the SP in Query Analyzer and works fine.
The Shared Data Source tested good for the connection.Mike,
Why I think this happens is that the development environment is parsing
the stored procedure to try and determine the resultset that will be
coming back. If it can't, it just gives up and returns the error
message. I've had this happen on procs that use temp tables primarily.
There are a several of ways to handle this.
1. Don't use the wizzard. Manually build your data source, manually key
in the column names for the result set. Some will advocate never using
the wizzard, but don't throw the baby out witht he bathwater...
2. Try entering the proc exec statement with any required parameters:
exec myproc 0, 'parm2'
once you get through the wizzard, change the data set from using the
Command Type of "Text" to use "StoredProcedure", and specify the
parameter(s)/values on the parameter tab.
3. Modify your procedure to return an empty result set that matches
what is normally returned. default your parameter(s) to Null and add a
check for @.parameter = null in the body of the proc. if it is null,
return the empty result set and return. This will give the wizzard
what it is looking for. One technique that worked for me was to
rewrite the proc so that any SELECT ... INTO statements that create and
populate temp tables are changed to explicit table creates and insert
statements. Using table variables instead of temp tables is also an
option, as the development environment parser seems to ignore them when
trying to determine the result set.
Hope this helps!
Regards,
Clayton
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment