Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing expression to SQL Stored Proc
Message
De
03/02/2005 20:58:06
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
00983652
Message ID:
00983723
Vues:
17
Exactly what I was looking for...

Yet again, THANKS SERGEY!

Aloha,

James
>James,
>
>You can build query string and run it using EXECUTE command (similar to VFP EXECSCRIPT()).
>
CREATE PROCEDURE QueryData (
>             @ScoreExpression nvarchar(50),
>             @tcZipExpression nvarchar(50))
>AS
>BEGIN
>	DECLARE @Sql nvarchar(4000)
>	SET @Sql = 'SELECT * FROM Table ' +
>  				' WHERE Score ' + @tcExpression +
>  				' AND ZIP ' + @tcZipExpression
>	EXECUTE (@Sql)
>
>END
>
You can as well build that query string in VFP and send to SQL Server for excution w/o creating stored procedure.
>
>>
>>Is it possible to pass an expression to a SQL Stored Procedure? Something to the effect of this:
>>
>>ScoreExpression=[BETWEEN '950' AND '1135']
>>ZipExpression=[LIKE '967%']
>>
>>CREATE PROCEDURE (QueryData @ScoreExpression NVARCHAR(50), @tcZipExpression NVARCHAR(50))
>>AS
>>BEGIN
>>  Select * From Table WHERE
>>    Score @tcExpression AND
>>    Zip @tcZipExpression
>>END
>>GO
>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform