Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replacing VFP Function with SQL Server
Message
From
09/10/2014 13:19:15
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2014
Application:
Web
Miscellaneous
Thread ID:
01609065
Message ID:
01609070
Views:
52
>select * from MyTable where DAYSTOCOMPLETE( DATE_CLOS, DATE_OPEN)>23)
>
>Where DATE_CLOS and DATE_OPEN are two column names of the table. Should this code work or I have to change the syntax?


First, I'd recommend always referencing the schema..... WHERE dbo.DaysToComplete....

Second, performance will be better if you do it inline....

WHERE DATEDIFF(D, OpenDate, CloseDate) > 23

I'm not a fan of scalar functions in SQL, because you can get really bad performance sometimes. Unless the benefit of a function is much higher than performance, it's better to use it inline.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform