samedi 27 mai 2017

SQL Server - What is the correct syntax?

Do I write the correct syntax?

pseudo code


select * from products
if @value is not null begin where category = @value end
+ if @value is not null begin where other1 = @value1 end
+ if @value is not null begin where other2 = @value2 end
+ if @value is not null begin where other3 = @value3 end

I am noob. I do not want to write a dynamic query. How to write the above query?

Aucun commentaire:

Enregistrer un commentaire