Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | jeptStarting Member
 
 
                                        14 Posts | 
                                            
                                            |  Posted - 2004-09-07 : 11:10:19 
 |  
                                            | I have created a program with dropdownlists.  The default for each dropdownlist is a dash.  Now what I want to do is be able to search information on a database that the dropdownlist are retrieving from.  When the dropdownlist are dashes I don't want the sql to take them in consideration.  I have 8 dropdownlist so if only one or two ddl are selected with value I just want the sql to just search for only those two that are selected.  Is there any suggestions for this quary statement? |  |  
                                    | spirit1Cybernetic Yak Master
 
 
                                    11752 Posts | 
                                        
                                          |  Posted - 2004-09-07 : 11:21:54 
 |  
                                          | i think this should be done in gui not in sql server.if u have a sproc don't pass the parameters that are dash and usewhere (ddl1 like @ddl1 or @ddl1 is null) and (ddl2 like @ddl2 or @ddl2 is null) and (...)if it's a direct sql statement ignore them when building the statement. Go with the flow & have fun! Else fight the flow   |  
                                          |  |  |  
                                    | jeptStarting Member
 
 
                                    14 Posts | 
                                        
                                          |  Posted - 2004-09-07 : 11:42:53 
 |  
                                          | Is there a way that I could ignore them in the sql statement if they are dashes.  I have put the selecteditems into variables for the sql statement.  Thats basically what I want to do is ignore the value if it is a dash. |  
                                          |  |  |  
                                    | ditchMaster Smack Fu Yak Hacker
 
 
                                    1466 Posts | 
                                        
                                          |  Posted - 2004-09-07 : 11:53:41 
 |  
                                          | perhaps something along these lines?[CODE]declare @param1 varchar(5)set @param1 = '2701'select *from branchwhere branchcode = (case when @param1 = '-' then  branchcode  else  @param1 end)set @param1 = '-'select *from branchwhere branchcode = (case when @param1 = '-' then  branchcode  else  @param1 end)[/CODE]Duane. |  
                                          |  |  |  
                                |  |  |  |