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:
01527342
Vues:
37
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