Tuesday, July 12, 2016

SSMS Slow Application Fast

I ran into a situation where the sp takes several minutes to run in SSMS and fraction of a second in Application. The Application calls this SP using Entity Framework.
After seeing the profile only difference between the EF and SSMS is the variable
set arithabort this is off in EF and on in SSMS
in SSMS then I ran
set arithabort off
and then ran my sp and it went faster.

To continue debugging the real issue I created a new sp as a back up of my sp and it ran faster even with set arithabort on!!
Puzzled I just ran alter in my sp and did no changes and just saved it.
Now even my sp runs faster!!

Same issue happened in another environment in which SSMS is faster and applicaiton is slower.
Once again did an alter save and now the sp runs faster in both modes

Wednesday, June 8, 2016

Beatpicker enable a date in a month

I have been using beatpicker. I had got into a situation wherein I need to enable only 1 date in a month for the current year. And the date has to be enabled after today's date.
So if I'm in March Feb and Jan date needs to be disabled.
The beatpicker has few limitations it has a limit on the number of items that can be mentioned in the disablingRules and another is lets say if I say                      
{ from: [*, *, 2], to: [*, *, 31] },
For months which has less than 31 days the date logic gets overflowed to the next month.
After trying various combinations the below code works well
disablingRules: [
                        { from: currentdate, to: '<' }, //diable less than today's date
                        { from: [currentYear, 1, 2], to: [currentYear, 1, 31] },
                        { from: [currentYear, 2, 2], to: [currentYear, 2, 28] },
                        { from: [currentYear, 3, 2], to: [currentYear, 3, 31] },
                        { from: [currentYear, 4, 2], to: [currentYear, 4, 30] },
                        { from: [currentYear, 5, 2], to: [currentYear, 5, 31] },
                        { from: [currentYear, 6, 2], to: [currentYear, 6, 30] },
                        { from: [currentYear, 7, 2], to: [currentYear, 7, 31] },
                        { from: [currentYear, 8, 2], to: [currentYear, 8, 31] },
                        { from: [currentYear, 9, 2], to: [currentYear, 9, 30] },
                        { from: [currentYear, 10, 2], to: [currentYear, 10, 31] },
                        { from: [currentYear, 11, 2], to: [currentYear, 11, 30] },
                        { from: [currentYear, 12, 2], to: '>' },//next year disable
                        { from: ['*', '*', '*'], to: ['*', '*', 29] }, // special case of disabline the date for feb in case of leap year

                        ],

You can populate the current year as a js variable