SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sql statement with conditions
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jept
Starting Member

USA
14 Posts

Posted - 09/07/2004 :  11:10:19  Show Profile  Reply with Quote
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?

spirit1
Cybernetic Yak Master

Slovenia
11751 Posts

Posted - 09/07/2004 :  11:21:54  Show Profile  Visit spirit1's Homepage  Reply with Quote
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 use
where (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
Go to Top of Page

jept
Starting Member

USA
14 Posts

Posted - 09/07/2004 :  11:42:53  Show Profile  Reply with Quote
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.
Go to Top of Page

ditch
Flowing Fount of Yak Knowledge

South Africa
1466 Posts

Posted - 09/07/2004 :  11:53:41  Show Profile  Visit ditch's Homepage  Reply with Quote
perhaps something along these lines?


declare @param1 varchar(5)
set @param1 = '2701'

select *
from branch
where branchcode = (case when @param1 = '-' then  branchcode  else  @param1 end)

set @param1 = '-'

select *
from branch
where branchcode = (case when @param1 = '-' then  branchcode  else  @param1 end)





Duane.

Edited by - ditch on 09/07/2004 11:54:32
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000