Friday, November 28, 2008

Query hints in SQL

Query hints, also referred to as optimizer hints, can dramatically affect the execution of a query, its index choices, as well as its locking behavior. In general SQL Server 2000, will choose the query plan that provides the best possible performance, so using optimizer hints should not be exercised "just in case". Instead, it is recommended that you troubleshoot and examine the query execution, then see if you can modify any of your table / index design to optimize the query. Then, as the last resort of a very troubled query, you can evaluate and test using query hints.

Thursday, November 20, 2008

SQL 2008 Features

1. Plug-in model for SSMS
2. Intellisense
3. Processing of delimited strings
4. Compression.
5. Resource governor
6. Plan freezing
7. C like math syntax
8. Auditing.
9. Inline variable assignment.

disabling right click

var isnn,isie
if(navigator.appName=='Microsoft Internet Explorer') //check the browser
{ isie=true }

if(navigator.appName=='Netscape')
{ isnn=true }

function right(e) //to trap right click button
{
if (isnn && (e.which == 3 || e.which == 2 ))
return false;
else if (isie && (event.button == 2 || event.button == 3))
{
alert("Sorry, you do not have permission to right click on this page.");
return false;
}
return true;
}

function key(k)
{
if(isie) {
if(event.keyCode==17 || event.keyCode==18 || event.keyCode==93) {
alert("Sorry, you do not have permission to press this key.")
return false;
}
}

if(isnn){
alert("Sorry, you do not have permission to press this key.")
return false; }
}

if (document.layers) window.captureEvents(Event.KEYPRESS);
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
document.onkeydown=key;
document.onmousedown=right;
document.onmouseup=right;
window.document.layers=right;

Put this code in a file called security.js and reference it between the HEAD tags of any html or asp page using:

Email Validation

function emailCheck(str) {

var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(at,(lat+1))!=-1){
alert("Invalid E-mail ID")
return false
}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(dot,(lat+2))==-1){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(" ")!=-1){
alert("Invalid E-mail ID")
return false
}

return true
}

allow only one space between to words

function checkSpace()
{
var flg=1;
var txt = document.getElementById('TextBox1').value;

var strArr = new Array();
strArr = txt.split(" ");
for(var i = 0; i < strArr.length ; i++)
{
if(strArr[i] == "")
{
alert("Only one space is allowed between words");
flg=0;
break;
}
}