Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamic Where Clause In Stored Procedure
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00634614
Message ID:
00637189
Vues:
27
>I think Sergey gave you the best answer.
>
>BTW, what are you using the row counts for?
>
>-Mike

Thanks Mike,
Sergey's answer confirmed my findings. The query I presented in the example was oversimplified. There is a WHERE clause attached to it. We have several tables (each with its own structure) that we require counts of available records based on several criteria. The user selects the criteria from a VFP interface, which then creates the SQL command and executes it on the selected table. My dilemma is that "both" the table and the WHERE clause are variables. I could write a usp for each table, but that would make maintenance a bit complex. Is there a way to execute a query with a fixed table but a variable WHERE clause without EXEC(@SQLcmd)?

SELECT COUNT(*)
FROM Publishers
WHERE @myClause

Thank you,
Aristotle
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform