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 |
|
sparrow37
Posting Yak Master
148 Posts |
Posted - 2010-11-02 : 08:04:33
|
| Hi all :I need to do following using T-SQLIf created_at_begin <> Null and created_at_end is Null then the where clause adds Created_At>= created_at_begin. If created_at_begin = Null and created_at_end <> Null then the where clause adds Created_At<= created_at_end. If created_at_begin <> Null and created_at_end<> Null then the where clause adds Created_At between created_at_begin and created_at_end.where created_at_begin and created_at_end are the parameters.Regards,Asif Hameed |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2010-11-02 : 08:29:58
|
| where created_at <= isNull(@created_at_end, created_at)and created_at >= isNull(@created_at_begin, created_at)Be One with the OptimizerTG |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-11-02 : 08:51:38
|
| orwhere (@created_at_end is null or created_at <= @created_at_end)and (@created_at_begin is null or created_at >= @created_at_begin)MadhivananFailing to plan is Planning to fail |
 |
|
|
sparrow37
Posting Yak Master
148 Posts |
Posted - 2010-11-02 : 08:53:34
|
| what about the between clause ? |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2010-11-02 : 11:28:06
|
| When both values are supplied then the two conditions together act as BETWEEN. Try it...Be One with the OptimizerTG |
 |
|
|
|
|
|