Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find the peak hour
Message
From
29/07/2014 03:22:12
 
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Environment versions
SQL Server:
SQL Server 2014
Application:
Web
Miscellaneous
Thread ID:
01604117
Message ID:
01604859
Views:
42
>>>http://social.technet.microsoft.com/wiki/contents/articles/25654.t-sql-find-the-peak-hour.aspx
>>
>>Snip : "a simple solution"
>>
>>If you call that simple what do you call 'complicated' :-}
>>
>>I raised this with Kevin : given the option of a simple CLR method (a small piece of code with more flexible options over the number of periods in the table and the span of the 'peak' period why on earth would you use this T-SQL ?
>
>Did you compare CLR solution with T-SQL in terms of speed?

No. But I'd make a small bet that a CLR solution would be as fast if not faster.
Data access is minimal (you're only looking at one row) . The rest is essentially just processing a array.
Snip (http://msdn.microsoft.com/en-us/library/ms131075(v=sql.100).aspx) :
"When Transact-SQL cursors must traverse data that is more easily expressed as an array, managed code can be used with significant performance gains."

If I find some time I'll test it.....

>Yes, for me that solution is simple, but the CLR solution would be more complex. I personally would only employ CLR solution when there is no simple T-SQL solution (or performant).

Our definitions of 'simple' differ. If it was simple Don wouldn't have raised the question in the first place (and, presumably, you would not have thought it worthwhile to post a solution on TechNet)
Previous
Reply
Map
View

Click here to load this message in the networking platform