Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can I Do Dynamic Query Construction in SQL Server SP
Message
De
11/10/2009 14:15:46
Bill Drew
Independent Consultant
Chicago, Illinois, États-Unis
 
 
À
11/10/2009 13:15:44
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
01428769
Message ID:
01428795
Vues:
56
>>I have a VFP query screen that has several text boxes for entry of a the necessary values for a look up by last, first, dob, year of claim, and two case id numbers. In the "Do Query" click code, I create an SQL Select statement which combines the variables based on a useful logic (ie last and first and dob can claim year can be combined using AND logic -- if either of the claim IDs are filled in then the logic is a simple search just on the ID. if "is contained in" is checked the target word is preceded with the %. With SQLEXED, It is a great tool. But the company policy is to use stored procedures.
>>
>>So now I'm trying to implement it as a stored procedure. But I don't have enough experience to write this conditional logic in the stored procedure. If I pass all the query variables to the SP, can I evaluate which ones are non null and conditionally execute one Select statement or another?? If so, how does this procedural code look?
>
>You can use
>
>Isnull( @theParameter, replacementValueIfParameterIsNull)
>
>or:
>
>case when @theParameter is NULL then ... else @theParameter end
>
>T-SQL also supports conditionals like If ... then ... else
>
>Cetin

Can you develop it a little more for me?

For example

Would I be about to conditionally call one SQL Select based on checking for Null parameters and call another SQL Select based on a different combination of Null and Non Null parameters??
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform