Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing parameters from VFP to Stored Procedures
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00554615
Message ID:
00554627
Views:
18
>Question...
>
>Many of our current VFP queries utilize macro-expansion heavily....we have many instances of...
>
>SELECT &cFldList FROM &cFileList WHERE &cJoin GROUP BY &cGroup
>
>We'd like to convert some of these to Stored Procs in SQL Server, and then use SQLEXEC from VFP to call them. However, I haven't been able to figure out the syntax in T-SQL. I'm interested in all the parameters (field list, file list, join clause, and group by), but specifically the group by...basically, having it be variable at runtime.
>
>Can this be done?
>
>Thanks,
>Kevin

Kevin,
It can be done but you probably won't get any benefit from it performance-wise. You would have to pass in all the parameters (clauses), concatenate them together and then pass them as one long SQL statement to the SP_EXECUTESQL system stored procedure to execute it.

SQL statement clauses are static. Ordinarily, you can only use parameters in the WHERE clause values not the WHERE clause field list. Since you want to make everything dynamic, nothing will be pre-compiled and optimized. It will have to be done on-the-fly for all calls.

IMO, I don't see any benfit to doing this. As I said, the performace won't increase and I don't see any benefit to the maintainability either. You are still building your SQL statements outside of SQL Server so there isn't a central location to maintain.

If I may ask, why do you want to do this?
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform