SQL Server : select with "Value or All" -


i have table t1 columns id1, id2.

i need write 1 "select" stored procedure this

create sp_gett1byid1andid2     @id1 varchar(50), @id2 varchar(50) begin     select *      t1                // if (id1 = "all" ,  id2 = "all") have return data in table t1          //  if (id1 = "all" , id2 != "all") have filter data according id2           //  if (id1 != "all" , id2 = "all") have filter data according id1          //  if (id1 != "all" , id2 != "all") have filter data according id1 , id2 end 

select * your_table (@id1 = 'all' or id1 =  @id1)   , (@id2 = 'all' or id2 =  @id2) 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -