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 |
|
wangyc77
Yak Posting Veteran
65 Posts |
Posted - 2007-02-08 : 21:22:22
|
| CREATE FUNCTION dbo.RJ_PriceRequest2( @ecity varchar(30), @ewkind varchar(40)) RETURNS TABLE ASRETURNselect ecity, ewkind from Tablewhere ecity=@ecity and ewkind=@ewkindI have 2 parameter in this function, but sometimes user will use only ecity (let say ecity=Tokyo, then no value for ewkind) and sometimes they will use both (say ecity=Tokyo, ewkind=Tobu). The first case it like he wants all result in Tokyo, and the second one is a more specific search. How do I let modify my function so it can achive this? Or I just have to make another function with one parameter only?Thanks**Jonathan** |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-08 : 22:11:49
|
[code]CREATE FUNCTION dbo.RJ_PriceRequest2( @ecity varchar(30), @ewkind varchar(40))RETURNS TABLEASRETURNselect ecity, ewkind from Table -- your table name herewhere ecity = coalesce(@ecity, ecity)and ewkind = coalesce(@ewkind, ewkind)[/code]What is your table name ? KH |
 |
|
|
wangyc77
Yak Posting Veteran
65 Posts |
Posted - 2007-02-09 : 07:27:03
|
| Thanks for helping, it is solved~~**Jonathan** |
 |
|
|
|
|
|