I want to be able to build a query with a variable amount of where statements. A user will be adding various conditions. Is there a way to make a query flexible? In Microsoft access I would write visual basic code and have it loop thru and add the various where statements. I am new to SQL server so excuse me if I don't have the terminology correct. Thanks for the help.
if you have a GUI, you can build the string in your GUI then execute the through Execute Method of your front-end tool the same way you to in MS Access. if you're planning to use stored procedure you can build your query by something like:
set @sqlstringvariable = 'select field from table'
set @sqlstringvariable = @sqlstringvariable + ' where ' + @condition1
set @sqlstringvariable = @sqlstringvariable + ' and ' + @condition2
then do a
exec ( @sqlstringvariable)