Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Function or Stored Procedure?
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01527340
Message ID:
01527360
Vues:
34
>Maybe computed column is what I am looking for. Because in VFP the MyDateFunc is a computed column (I just didn't remember this term). I will have to look into how to create those. Thank you.

This is very simple in both table designer or a script.

>
>>If you want to mimic VFP, it will be user defined scalar function or computed column.
>>
>>If the function can be written using inline logic, then I suggest a computed persisted column.
>>
>>Also, just to explain - you can call UDFs in a query, but you can not call stored procedure in a query
>>
>>(Except for
>>
>>insert into ...
>>exec mySP @Param1, @param2 ...
>>)
>>
>>>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.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform