Posts

Showing posts from April, 2008

Case Sensitive or Insensitive SQL Query

Suppose you need to perform a SQL query and you need for it to be case sensitive or case insensitive, and either your database is set up the opposite way or you're smart and you're trying to write your query so that it will work regardless of how the database may or may not be configured. For instance, consider this query: SELECT UserId, email FROM UserInfo WHERE email = 'ashvin@padhiyar.com' If your database contains an email for Bill like this one: ASHVIN@padhiyar.com then whether or not your query will return any rows will depend on the COLLATION for the database. If you want to ensure that you DO get results, you can force it to use a CASE INSENSITIVE collation like so: SELECT UserId, email FROM UserInfo WHERE email = 'ashvin@padhiyar.com' COLLATE SQL_Latin1_General_CP1_CI_AS Similarly, if you don't want it to return any rows unless you specify the correct case for the email, you would change the collation to replace _CI_ with _CS_ where CI is shor

Print Function By JavaScript

function PrintContent( Obj) { PrintWin=window.open('','PrintWin','directories=no, location=no, menubar=no, resizable=no, status=no, toolbar=no, scrollbars=no, width=10, height=10, left=1050, top=800'); PrintWin.document.write(" "); PrintWin.document.write(document.getElementById(Obj.id).outerHTML); PrintWin.location.reload(); PrintWin.print(); PrintWin.close(); } /************* Function call ***************/ btnPrint.Attributes.Add( "OnClick", "PrintContent(" + TblPrint.ClientID + ");");

Email Validation by Javascript

function EmailCheck() { var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; var str =document.getElementById('<%= TxtTo.ClientID %>').value; if(reg.test(str) == false) { alert('Invalid Email Address'); document.getElementById('<%= TxtTo.ClientID %>').focus(); } }

Getting Top N Rows in SQL2K and SQL2K5 [Non Tech Ppl Plz Excuse]

SQL 2K declare @topN int set @topN = 10 set rowcount @topN select * from [TABLE] /***************************/ SQL 2K5 declare @topN int set @topN = 5 select top ( @topN ) * from [TABLE]