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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Parameter problem in UDF

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
AS
RETURN

select ecity, ewkind from Table
where ecity=@ecity and ewkind=@ewkind


I 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 TABLE
AS
RETURN
select ecity, ewkind from Table -- your table name here
where ecity = coalesce(@ecity, ecity)
and ewkind = coalesce(@ewkind, ewkind)
[/code]

What is your table name ?


KH

Go to Top of Page

wangyc77
Yak Posting Veteran

65 Posts

Posted - 2007-02-09 : 07:27:03
Thanks for helping, it is solved~~



**Jonathan**
Go to Top of Page
   

- Advertisement -