Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL 2000 UDFs for common VFP functions?
Message
From
15/10/2002 15:02:29
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00711104
Message ID:
00711444
Views:
13
This message has been marked as a message which has helped to the initial question of the thread.
Dan,

>Has anyone duplicated (or failed to duplicate) common VFP functions as SQL 2000 UDFs? Looks like a good way to easy the transition of VFP views which are littered with IIF(), NVL(), etc.

See my other message for STREXTRACT sample. Note that you may have to GRANT permissions after setting these up, and that they may have to be called with the dbo. in front, although I'm not sure of all the rules regarding that.

HEre are two simple ones for TTOC and DTOS:
CREATE  FUNCTION [dbo].[TTOC]
    ( @dDate AS DateTime ) 

RETURNS varchar(10)

AS

BEGIN 

RETURN   RIGHT('0'+LTRIM(CAST(DATEPART(mm,@dDate) AS varchar(2))),2)+ '/' +
  RIGHT('0'+LTRIM(CAST(DATEPART(dd,@dDate) AS varchar(2))),2) + '/' + 
  CAST(DATEPART(yyyy,@dDate) AS varchar(4))
END 
GO
CREATE  FUNCTION [dbo].[DTOS] 
    ( @dDate AS DateTime ) 

RETURNS varchar(8)

AS

BEGIN 

RETURN CAST(DATEPART(yyyy,@dDate) AS varchar(4)) + 
  RIGHT('0'+LTRIM(CAST(DATEPART(mm,@dDate) AS varchar(2))),2)+
  RIGHT('0'+LTRIM(CAST(DATEPART(dd,@dDate) AS varchar(2))),2)
END 
GO
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform