What is better, dynamic SQL or where case?
问题 I need to create a stored procedure which takes 12 arguments and the query is filtered with a different combination of this arguments. All 12 arguments are not mandatory as if I pass 3 or 5 or 12 arguments depends on search inputs entered by user. I can create 2 ways, either using a dynamic SQL query or using 'Case where' statements. Example of these queries are as below: Dynamic Query DECLARE @sql VARCHAR(MAX) DECLARE @condition VARCHAR(MAX)='' Declare @var1 varchar(10) Declare @var2 varchar