Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incorrect syntax in SQL stored procedure

Status
Not open for further replies.

akuchin

IS-IT--Management
May 7, 2002
14
0
0
US
I run into a strange problem when I tried to create a report off of SQL stored procedure. I thought one of you may encounter similar problem, so here it is and the solution to it.
Basically, I had to dynamically define a table that I will be pulling data from. For that purpose I have defined a variable called @table and then used a statement "EXEC "select * from "+@table+"" to retrieve data from this table.
That worked out ok in Query Analyzer, but would not work in Crystal which returned the error message "Incorrect syntax by the keyword 'from'". The solution: Once I have made @table to be a char variable instead of varchar it worked fine.
 
Would this same approach work if you needed to frequently change the name of the stored procedure you used in a report?
 
Akuchin: You might want to include the version of Crystal used, Type, version and service pack of the database, and the type of connectivity, and if you tested other types of connectivity.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top