Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UDF in SQL Server 2K
Message
From
21/11/2002 19:44:26
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00724953
Message ID:
00725555
Views:
15
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.
Previous
Reply
Map
View

Click here to load this message in the networking platform