Tuesday, February 21, 2012

insufficient memory to complete operation

If you execute any script in SQL SEVER (Any Database) and you got any error "insufficient memory to complete operation" like this,
then please use GO statement after 50 rows or 100 rows just an example. If  you execute  any script which has around 65,000 update statement with out any GO statement. Now in this time SQL SERVER is assuming this is single BATCH which has 65,000 rows and its trying to execute in single shot and it will give a error "insufficient memory to complete operation".

For resolving this issue please add GO statement after some of the rows(Like 50 or 100).And its assuming we have so many BATCHES and executed successfully without any error.

Thanks,
Kapil.

Thursday, February 16, 2012

Indian Standard Time and GMT from Local Time Using JavaScript/Jquery NOT CONSIDERING TIMEZONE UTC TIMEOFFSET


Written below is the function I wrote in order to get IST. Needless to say, the IST displayed will be just as accurate as accuracy of host computer.


In that case we need to get UTC date and add the difference minutes to it before display. For example if your database server is in India then you need to add 330 minutes (5 hours 30 minutes) to UTC time to get the correct database time in the client machine.Because the conversion in JSON will automatically happen internally
based on client machine's time zone.

Whenever we changed TIMEZONE date will be changed based on TIME ZONE (UTC OFFSET) but we do not need to consider time at all we need to display on DATE which is existed in our DATABASE use the below FUNCTION based on  your requirement.


/***Get Indian Standard Time from visitor’s local computer time.
Add getTimezoneOffset to get GMT/UTC
Add +330 minutes (IST is +5.5 hrs ahead of GMT) to get IST
***/function getCurrentIST(){
var dte = new Date();
dte.setTime(dte.getTime() +(dte.getTimezoneOffset()+330)*60*1000);
document.write(dte.toLocaleString());
}

The function written below, converts GMT time string into visitor’s local time, takes care of Daylight Savings too.

/***Get visitor’s Local Time from from GMT time string
sTime : Input date/time/timestamp format string
Any string parsable by Date.parse()
static method is accepted as input.
***/function getLocalTimeFromGMT(sTime){
var dte = new Date(sTime);
dte.setTime(dte.getTime()- dte.getTimezoneOffset()*60*1000);
document.write(dte.toLocaleString());
}
getTime()
Returns the numeric value corresponding to the time for the specified date according to local time from the visitor’s computer. The value returned by the getTime method is the number of milliseconds since 1 January 1970 00:00:00.

getTimezoneOffset()
Returns the time-zone offset in minutes for the current locale, including Daylight savings time, from visitor’s computer. The time-zone offset is the difference between local time and Greenwich Mean Time(GMT).

toLocaleString()
Converts a date to a string, using the current locale’s conventions. Different platforms might assemble the input string in different ways depending on the user agent (browser) and operating system settings.