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 |
|
rongrace
Starting Member
13 Posts |
Posted - 2012-03-07 : 09:29:10
|
| I have a form that returns order details based on the input received in 4 parametersusing the following WHERE clauseWHERE HOrder.Acno = @Acno andSUBSTRING(HDespatch.ArcOrdno,1,4) = @Unit andSUBSTRING(HDespatch.ArcOrdno,5,8) >= @FromDate andSUBSTRING(HDespatch.ArcOrdno,5,8) <= @ToDateThe current WHERE clause expects all these fields to contain data, but I want to expand the clause so that it will cater for the following.If the Acno is blank then it will return all the orders for the unit within the date range.If the unit is blank it will return all orders for the Acno for the date range entered.If the date range is blank it will return all the Acno's orders for that unitHope this makes sense and any help would be much appreciated |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
|
|
rongrace
Starting Member
13 Posts |
Posted - 2012-03-07 : 09:43:23
|
| Thanks for that, I'll have a shufty |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-07 : 19:07:17
|
| why is value stored in a concatenated format in field? why not maintain date value in its own field?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
rongrace
Starting Member
13 Posts |
Posted - 2012-03-08 : 04:50:57
|
| Data came from a legacy system in that format |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2012-03-08 : 08:30:56
|
| so change it to a real date. that is the best part of having a new system.http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-08 : 10:15:44
|
quote: Originally posted by rongrace Data came from a legacy system in that format
just keep in mind that persisting with it will really make manipulations complex. everywhere you use the individual parts you've to apply SUBSTRING functions and get them which will also have an adverse effect on performance too.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|