Thanks Sergey for the example. I will look into this.
Regards.
>You can create UDF in Sql 2000. Here's the sample of such function.
-- =============================================
>-- Create scalar function (FN)
>-- =============================================
>IF EXISTS (SELECT *
> FROM sysobjects
> WHERE name = N'test_function')
> DROP FUNCTION test_function
>GO
>CREATE FUNCTION test_function
> (@dt datetime,
> @p2 int)
>RETURNS int
>AS
>BEGIN
> RETURN CASE
> WHEN @p2=1 THEN DATEPART(yy, @dt) -- Year
> WHEN @p2=2 THEN DATEPART(mm, @dt) -- Month
> WHEN @p2=3 THEN DATEPART(dd, @dt) -- Day
> ELSE Null END
>END
>GO
>USE pubs
>SELECT dbo.test_function(ord_date,2), * FROM sales
>
>>Hi all,
>>
>>In VFP, I can do a SQL Select like this :
>> SELECT cnoee,cname,dage(demas.dbirth) FROM demas
>>
>>If I want to do the same in SQL Server, do I create a User Defined Function for dage in "Enterprise Manager"?
>>
>>Can someone direct me the correct direction? Some short syntax would be greatly appreciated, :) . If I want to analyse the age of the employee by passing a date, how will I accomplish that? Normally I will pass dage(demas.dbirth,pdanalysis) where pdanalysis is the private variable..
>>
>>Regards.