Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL 2000 UDFs for common VFP functions?
Message
 
 
To
15/10/2002 15:02:29
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00711104
Message ID:
00711548
Views:
7
Hi David,

The first function isn't TTOC() because it doesn't return the time part. You can also simplify both of those functions by using SQL Server specific function CONVERT()
* TTOC
RETURN CONVERT(char(10), @dDate, 101) + ' ' + CONVERT(char(8), @dDate, 114)
* DTOS 
RETURN CONVERT(char(10), @dDate, 112)
>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
>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform