You see, in order for my code to work equally for VFP and SQL Server and use SF Query I have to have the SQL Server "recognize" the call to MyDateFunc(). I will try to create a small stored procedure and see what kind of error I get (if any). Thank you.
>I suggest avoid creating scalar UDFs (as they don't scale well) and try to incorporate the logic into the main query. If the query is too complex, it can be a stored procedure.
>
>User Defined Function (scalar) can be an option, but don't overuse it.
>
>Also, you can have computed column in SQL Server. It can be persisted and indexed. So, this is another possibility to consider.
>
>Also consider a view in SQL Server.
>
>>Hi,
>>
>>This one is a truly newbie question.
>>
>>I need to create either a stored procedure or a function to serve the following purpose:
>>
>>In my VFP application, in Stonefield SDT, a table has a user-defined field (e.g. MyDateFunc). This function passes two field values, Date1 and Date2. So in the SDT this field/function defined as
>>
>>MyDateFunc( Date1, Date2 )
>>
>>
>>This function therefore is in my application database container. Then, using SF Query, I can use this field to query the database. For example, the query could be like this:
>>
>>select * from MyTable where MyDateFunc( Date1, Date2) > 3
>>
>>
>>In my VFP application there is actually this function, MyDateFunc, that takes two dates as parameters and returns the difference.
>>
>>When using SQL server this fails. Obviously because SQL Server does not have function MyDateFunc.
>>
>>So my question is, in order for the SQL Select to work against SQL Server, should I create a function MyDateFunc in SQL server or a Stored Procedure MyDateFunc?
>>
>>TIA.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham