<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3425640466761138561</id><updated>2011-11-27T15:58:00.777-08:00</updated><category term='Javascript'/><category term='SQL Server'/><title type='text'>WebDeveloper's Corner</title><subtitle type='html'>Hi Friends.. i am a web developer from india and here i would like to share my experience with you.. Sometimes i may be wrong so help me to improve..</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-6658911056891504755</id><published>2008-03-12T00:10:00.000-07:00</published><updated>2008-03-12T00:15:38.638-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Return Null If A Value Is A Certain Value</title><content type='html'>Sometimes you may have to return a Null value if  the value of your data is a certain value. Here&lt;br /&gt;i have given some ways to do this... check it out..&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;strong&gt;NULLIF&lt;/strong&gt;&lt;br /&gt;DECLARE @1 char(1)&lt;br /&gt;SELECT @1 ='D'&lt;br /&gt;&lt;br /&gt;SELECT NULLIF(@1,'D')&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;REPLACE&lt;/strong&gt;&lt;br /&gt;This should not really be used, I just added it here to demonstrate that you can in fact use it.&lt;br /&gt;&lt;br /&gt;DECLARE @1 char(1)&lt;br /&gt;SELECT @1 ='D'&lt;br /&gt;&lt;br /&gt;SELECT REPLACE(@1,'D',NULL)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;CASE&lt;/strong&gt;&lt;br /&gt;With case you can test for a range of values. You can test for example for values between A and D. If you reverse the logic then you also don't need to provide the ELSE part since it defaults to NULL anyway.&lt;br /&gt;&lt;br /&gt;DECLARE @1 char(1)&lt;br /&gt;SELECT @1 ='D'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT CASE @1 WHEN 'D' THEN NULL ELSE @1 END&lt;br /&gt;&lt;br /&gt;--No else needed&lt;br /&gt;SELECT CASE WHEN @1 &lt;&gt; 'D' THEN @1 END&lt;br /&gt;&lt;br /&gt;And this is how you test for a range.&lt;br /&gt;&lt;br /&gt;--Null&lt;br /&gt;DECLARE @1 char(1)&lt;br /&gt;SELECT @1 ='D'&lt;br /&gt;&lt;br /&gt;SELECT CASE WHEN @1 BETWEEN 'A' AND 'D' THEN NULL ELSE @1 END&lt;br /&gt;&lt;br /&gt;--E&lt;br /&gt;DECLARE @1 char(1)&lt;br /&gt;SELECT @1 ='E'&lt;br /&gt;&lt;br /&gt;SELECT CASE WHEN @1 BETWEEN 'A' AND 'D' THEN NULL ELSE @1 END&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-6658911056891504755?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/6658911056891504755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/return-null-if-value-is-certain-value.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/6658911056891504755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/6658911056891504755'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/return-null-if-value-is-certain-value.html' title='Return Null If A Value Is A Certain Value'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-2608301485722653319</id><published>2008-03-11T23:12:00.000-07:00</published><updated>2008-03-11T23:15:49.195-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Retrieve TOP and BOTTOM Rows using SQL Query</title><content type='html'>Here my table name is &lt;strong&gt;MT_Sample_Info&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT *&lt;br /&gt;   FROM MT_Sample_Info&lt;br /&gt;   WHERE sid IN (&lt;br /&gt;   SELECT TOP 1 MIN(sid) sid&lt;br /&gt;       FROM MT_Sample_Info&lt;br /&gt;       UNION ALL&lt;br /&gt;   SELECT TOP 1 MAX(sid) sid&lt;br /&gt;       FROM MT_Sample_Info)&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-2608301485722653319?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/2608301485722653319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/retrieve-top-and-bottom-rows-using-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/2608301485722653319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/2608301485722653319'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/retrieve-top-and-bottom-rows-using-sql.html' title='Retrieve TOP and BOTTOM Rows using SQL Query'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-2578087341916955016</id><published>2008-03-11T02:22:00.000-07:00</published><updated>2008-03-11T02:24:28.313-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>SQL Query to find first day of month?</title><content type='html'>This is an interview question i have faced in most of the companies....&lt;br /&gt;&lt;br /&gt;it's looks easy but it will trouble you at the interview hall........&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT DATENAME(dw, DATEADD(dd, - DATEPART(dd, GETDATE()) + 1, GETDATE())) AS FirstDay&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-2578087341916955016?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/2578087341916955016/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/sql-query-to-find-first-day-of-month.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/2578087341916955016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/2578087341916955016'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/sql-query-to-find-first-day-of-month.html' title='SQL Query to find first day of month?'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-5209352091171533101</id><published>2008-03-11T01:47:00.000-07:00</published><updated>2008-03-11T02:19:36.436-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>SQL Query to export data from sql server to excel</title><content type='html'>– Create one Excel File in c:\Test.xls and rename the Sheet1 to Emp. The Sheet should contain 2 columns EmployeeID,Title&lt;br /&gt;&lt;br /&gt;USE [Production]&lt;br /&gt;&lt;br /&gt;INSERT INTOOPENROWSET(‘Microsoft.Jet.OLEDB.4.0′,‘Excel8.0;Database=c:\Test.xls;’,‘Select * from [Emp$]’)&lt;br /&gt;&lt;br /&gt;Select EmployeeID, Title FROM Employment.Employee&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-5209352091171533101?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/5209352091171533101/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/sql-query-to-export-data-from-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/5209352091171533101'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/5209352091171533101'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/sql-query-to-export-data-from-sql.html' title='SQL Query to export data from sql server to excel'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-591243452512524320</id><published>2008-03-11T01:46:00.000-07:00</published><updated>2008-03-11T01:47:36.025-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Creating a Delimited List in SQL Server without Cursors or Looping Using Coalesce or IsNull</title><content type='html'>Suppose you wanted to return a list of names from a Customer table in a database in a comma delimited list. You could create a SQL Query and loop through the rows with a cursor or you could return the result set and loop through it your application code, but there is another alternative. You can use this clever bit of SQL code:&lt;br /&gt;&lt;br /&gt;declare @MyList varchar(1000)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT  @MyList = Coalesce(@MyList + ', ', '') + field_name&lt;br /&gt;&lt;br /&gt;from table_name&lt;br /&gt;&lt;br /&gt;print @MyList&lt;br /&gt;You can also substitute IsNull for Coalesce when I first heard about this technique Coalesce was used, but IsNull seems to work just as well. The reason it works is because as the select takes place it appends the field value to the variable for each row in the result set. The IsNull or Coalesce will keep it from putting a delimiter in front of the first item&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-591243452512524320?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/591243452512524320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/creating-delimited-list-in-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/591243452512524320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/591243452512524320'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/creating-delimited-list-in-sql-server.html' title='Creating a Delimited List in SQL Server without Cursors or Looping Using Coalesce or IsNull'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-2765777017849070846</id><published>2008-03-07T00:12:00.002-08:00</published><updated>2008-03-07T00:17:37.023-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Removing a constraint from a table</title><content type='html'>Here i have given the syntax and query for removing a constraint from a table...&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;syntax&lt;/strong&gt;:&lt;br /&gt;------&lt;br /&gt;ALTER TABLE (tbl name) DROP CONSTRAINT (CONSTRAINT name)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Eg&lt;/strong&gt;:&lt;br /&gt;--&lt;br /&gt;ALTER TABLE Proddet_Details DROP CONSTRAINT   FK_PCIT_Details&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-2765777017849070846?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/2765777017849070846/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/removing-constraint-from-table.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/2765777017849070846'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/2765777017849070846'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/removing-constraint-from-table.html' title='Removing a constraint from a table'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-4697055898282869095</id><published>2008-03-06T21:49:00.000-08:00</published><updated>2008-03-06T23:26:01.411-08:00</updated><title type='text'>How to find 5th maximum number through a query in sql</title><content type='html'>"How do I find &lt;strong&gt;Nth&lt;/strong&gt; maximum value?" is one of the most asked questions in many&lt;br /&gt;  &lt;br /&gt;  interviews....  Here are some methods.. to solve this..&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Use Inner Join&lt;/strong&gt;&lt;br /&gt;------------------&lt;br /&gt;  select t1.num from number t1 inner join number t2 on t1.num&lt;=t2.num  group by     t1.num having count(t1.num)=5&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;Use Top Operator&lt;/strong&gt;&lt;br /&gt;---------------------&lt;br /&gt;&lt;strong&gt;Eg1&lt;/strong&gt;:&lt;br /&gt;Select top 1 num from(Select top 5 num from number order by num desc) T&lt;br /&gt;order by num asc&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Eg2&lt;/strong&gt;:&lt;br /&gt;Select TOP 1 quantity from findmax where quantity NOT IN (Select TOP 4 quantity FROM findmax order  by quantity ASC)&lt;br /&gt;order by quantity ASC&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-4697055898282869095?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/4697055898282869095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/how-to-find-5th-maximum-number-through.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/4697055898282869095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/4697055898282869095'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/how-to-find-5th-maximum-number-through.html' title='How to find 5th maximum number through a query in sql'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-6165414446977189475</id><published>2008-03-06T21:35:00.000-08:00</published><updated>2008-03-06T21:48:27.483-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>How to copy structure of table</title><content type='html'>&lt;strong&gt;syntax&lt;/strong&gt;:&lt;br /&gt;---------&lt;br /&gt;&lt;strong&gt;Select * Into (DestinationTableName) From (SourceTableName) Where 1 = 2&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br /&gt;-----------&lt;br /&gt;&lt;strong&gt;Select&lt;/strong&gt;&lt;strong&gt; * &lt;/strong&gt;&lt;strong&gt;Into&lt;/strong&gt;&lt;strong&gt; my_new_table &lt;/strong&gt;&lt;strong&gt;From&lt;/strong&gt;&lt;strong&gt; emp &lt;/strong&gt;&lt;strong&gt;Where&lt;/strong&gt;&lt;strong&gt; 1=2&lt;/strong&gt;&lt;br /&gt; &lt;destinationtablename&gt;&lt;sourcetablename where="" 1="2" destinationtablename=""&gt;&lt;br /&gt;&lt;br /&gt;&lt;destinationtablename&gt;Friends ....this will just create the table structure as the source table&lt;br /&gt;&lt;br /&gt;Wont create any constraint or triggers on the table..&lt;br /&gt;&lt;br /&gt;and if you also want to copy the data then remove the  &lt;destinationtablename&gt;&lt;strong&gt;where&lt;/strong&gt; &lt;/destinationtablename&gt;&lt;destinationtablename&gt;clause..  &lt;br /&gt;&lt;br /&gt;&lt;/destinationtablename&gt;&lt;destinationtablename&gt;&lt;sourcetablename where="" 1="2" destinationtablename=""&gt;&lt;destinationtablename&gt;Friends&lt;/destinationtablename&gt;&lt;destinationtablename&gt;&lt;sourcetablename where="" 1="2" destinationtablename=""&gt;&lt;destinationtablename&gt;&lt;destinationtablename&gt; post  your comments or questions  on my blog to improve my posts .... &lt;/destinationtablename&gt;&lt;strong&gt;&lt;destinationtablename&gt;&lt;sourcetablename where="" 1="2" destinationtablename=""&gt;&lt;strong br=""&gt;&lt;destinationtablename&gt;&lt;strong&gt;&lt;destinationtablename&gt;&lt;strong br=""&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/destinationtablename&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-6165414446977189475?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/6165414446977189475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/how-to-copy-structure-of-table.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/6165414446977189475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/6165414446977189475'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/03/how-to-copy-structure-of-table.html' title='How to copy structure of table'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-1634368054860719734</id><published>2008-02-26T02:04:00.000-08:00</published><updated>2008-02-26T02:34:33.727-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><title type='text'>Javascript : Disable  Right Click</title><content type='html'>You can disable right click on ur webpages to prevent others stealing ur images and other things...  place  this code above head tag..&lt;br /&gt;&lt;br /&gt;//script language="JavaScript"&lt;br /&gt;&lt;br /&gt;var message="Sorry, that function is disabled.";&lt;br /&gt;&lt;br /&gt;function click(e) {&lt;br /&gt;if (document.all) {&lt;br /&gt;if (event.button == 2) {&lt;br /&gt;alert(message);&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;if (document.layers) {&lt;br /&gt;if (e.which == 3) {&lt;br /&gt;alert(message);&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;if (document.layers) {&lt;br /&gt;document.captureEvents(Event.MOUSEDOWN);&lt;br /&gt;}&lt;br /&gt;document.onmousedown=click;&lt;br /&gt; &lt;br /&gt;// /script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-1634368054860719734?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/1634368054860719734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/02/javascript-disable-right-click.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/1634368054860719734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/1634368054860719734'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/02/javascript-disable-right-click.html' title='Javascript : Disable  Right Click'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-6123104158641476620</id><published>2008-02-23T00:54:00.000-08:00</published><updated>2008-03-07T00:19:28.873-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>How to use IN operator ?</title><content type='html'>Sometimes you want to test a given value against a list of values. Here you can  use the special comparison operator IN to get it done. Below i have given two examples using IN operator..&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Example 1:&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;DECLARE @my_id INT;&lt;br /&gt;SET @my_id = 767;&lt;br /&gt;SELECT CASE WHEN&lt;br /&gt; @my_id IN (525, 272, 532, 767, 150, 637)&lt;br /&gt;THEN 'I m Kavya.'&lt;br /&gt;ELSE 'I m not Kavya.'&lt;br /&gt;END;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;o/p: &lt;/strong&gt;I m Kavya&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;DECLARE @my_id INT;&lt;br /&gt;SET @my_id = 676;&lt;br /&gt;SELECT CASE WHEN&lt;br /&gt; @my_id NOT IN (525, 272, 532, 767, 150, 637)&lt;br /&gt;THEN 'I m not Kavya.'&lt;br /&gt;ELSE 'I m Kavya.'&lt;br /&gt;END;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;o/p: &lt;/strong&gt;I m not Kavya&lt;strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-6123104158641476620?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/6123104158641476620/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/02/how-to-use-in-operator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/6123104158641476620'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/6123104158641476620'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/02/how-to-use-in-operator.html' title='How to use IN operator ?'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-429560345173035142</id><published>2008-02-19T05:07:00.000-08:00</published><updated>2008-03-07T00:19:53.680-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>How To Test Subquery Results with the EXISTS Operator?</title><content type='html'>EXISTS is a special operator used to test subquery results. EXISTS can be used in two ways:&lt;br /&gt;&lt;br /&gt;EXISTS (SELECT ...)&lt;br /&gt;-- Returns TRUE if the specified subquery has one or more rows returned.&lt;br /&gt;&lt;br /&gt;NOT EXISTS (SELECT ...)&lt;br /&gt;-- Returns TRUE if the specified subquery no rows returned.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br /&gt;&lt;br /&gt;-- &lt;i&gt;Number of customers with orders&lt;/i&gt;&lt;br /&gt;SELECT COUNT(*) FROM SalesLT.Customer c WHERE&lt;br /&gt;EXISTS&lt;br /&gt;(SELECT * FROM SalesLT.SalesOrderHeader s WHERE s.CustomerID = c.CustomerID)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-- &lt;i&gt;Number of customers without orders&lt;/i&gt;&lt;br /&gt;SELECT COUNT(*) FROM SalesLT.Customer c WHERE&lt;br /&gt;NOT EXISTS&lt;br /&gt;(SELECT * FROM SalesLT.SalesOrderHeader s WHERE s.CustomerID = c.CustomerID)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-429560345173035142?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/429560345173035142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/02/how-to-test-subquery-results-with.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/429560345173035142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/429560345173035142'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/02/how-to-test-subquery-results-with.html' title='How To Test Subquery Results with the EXISTS Operator?'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3425640466761138561.post-1611416750189078811</id><published>2008-02-19T00:15:00.000-08:00</published><updated>2008-03-07T00:20:10.874-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Pattern matching - One or more occurances of a character</title><content type='html'>Here is the issue.&lt;br /&gt;&lt;br /&gt;I have a table like this..&lt;br /&gt;&lt;br /&gt;create table abcCollection(abc varchar(30) not null)&lt;br /&gt;&lt;br /&gt;And I insert the following data&lt;br /&gt;&lt;br /&gt;INSERT abcCollection values('ABC')&lt;br /&gt;INSERT abcCollection values('ABxC')&lt;br /&gt;INSERT abcCollection values('ABBBC')&lt;br /&gt;INSERT abcCollection values('ABBBBxBC')&lt;br /&gt;INSERT abcCollection values('ABxBBBBBBBC')&lt;br /&gt;INSERT abcCollection values('123ABBBC456AB')&lt;br /&gt;INSERT abcCollection values('dfdfddsds')&lt;br /&gt;INSERT abcCollection values('acdaccdbbvfcab')&lt;br /&gt;INSERT abcCollection values('acbcabbbfc')&lt;br /&gt;INSERT abcCollection values('acbcabbbfc')&lt;br /&gt;INSERT abcCollection values('abbbcafffc')&lt;br /&gt;INSERT abcCollection values('acabc')&lt;br /&gt;INSERT abcCollection values('acac')&lt;br /&gt;INSERT abcCollection values ('abbdddbbc')&lt;br /&gt;INSERT abcCollection values ('abbdddbabc')&lt;br /&gt;&lt;br /&gt;Now I want to get the following result&lt;br /&gt;&lt;br /&gt;ABC&lt;br /&gt;ABBBC&lt;br /&gt;123ABBBC456AB&lt;br /&gt;abbbcafffc&lt;br /&gt;acabc&lt;br /&gt;abbdddbabc&lt;br /&gt;&lt;br /&gt;That is, the result should contain A followed by one or more Bs followed by C. This pattern can appear anywhere within the string.&lt;br /&gt;&lt;br /&gt;We cannot directly use the LIKE operator since it doesn't support this kind of a search.&lt;br /&gt;&lt;br /&gt;There are quite a few methods to solve this. I am including all the solutions here.&lt;br /&gt;&lt;br /&gt;The following methods will work for SQL Server 2000 and 2005.&lt;br /&gt;&lt;br /&gt;Method 1: Call a recursive function.&lt;br /&gt;This function keeps replacing 2 continous Bs with a single B till it doesn't find any and then search for 'ABC'&lt;br /&gt;&lt;br /&gt;create function dbo.fn1(@input varchar(30))&lt;br /&gt;returns bit&lt;br /&gt;as&lt;br /&gt;begin&lt;br /&gt;return case when @input like '%abc%' then 1&lt;br /&gt;when charindex('bb',@input) &gt; 0 then dbo.fn1(replace(@input,'bb','b'))&lt;br /&gt;else 0 end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;And you can call the function like this..&lt;br /&gt;&lt;br /&gt;select abc from abcCollection where dbo.fn1(abc) = 1&lt;br /&gt;&lt;br /&gt;But, This is based on recursion and you can nest it only 32 times. So if your text has more than 32 Bs continously, then it might fail and its performance intensive too.&lt;br /&gt;&lt;br /&gt;Method 2: Use a while loop within the function.&lt;br /&gt;The logic of this function is similar to Method 1 with a different implementation.&lt;br /&gt;&lt;br /&gt;create function fn1 (@str as varchar(30)) returns varchar(30)&lt;br /&gt;as&lt;br /&gt;begin&lt;br /&gt;while (PATINDEX('%BB%', @str) &gt; 0)&lt;br /&gt;begin&lt;br /&gt;set @str = replace (@str,'BB','B')&lt;br /&gt;end&lt;br /&gt;return @str&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;And you can call the function this way:&lt;br /&gt;&lt;br /&gt;select abc from abcCollection where PATINDEX ('%ABC%', dbo.fn1(abc)) &gt; 0&lt;br /&gt;&lt;br /&gt;While this will work for big strings, you will have to execute a while loop for every column and so its performance intensive.&lt;br /&gt;&lt;br /&gt;Method 3: Filter in the query (smart replace)&lt;br /&gt;This solution is an absolute brainer, originally conceived by Robert Carnegie a long time back, shown to me by Steve Kass:&lt;br /&gt;&lt;br /&gt;select abc from abcCollection where&lt;br /&gt;replace(replace(replace(abc,'B','&lt;&gt;'),'&gt;&lt;',''),'&lt;&gt;','B')&lt;br /&gt;like '%ABC%'&lt;br /&gt;&lt;br /&gt;Here is how it works:&lt;br /&gt;Take for example you have the string 'ABBBC'&lt;br /&gt;First replace will replace 'B' with '&lt;&gt;'&lt;br /&gt;So the string becomes A&lt;&gt;&lt;&gt;&lt;&gt;C&lt;br /&gt;The Second replace will replace '&gt;&lt;' with an empty string( '' ) So A&lt;&gt;&lt;&gt;&lt;&gt;C becomes A&lt;&gt;C&lt;br /&gt;Now the third replace replaces '&lt;&gt;' with 'B'&lt;br /&gt;So it becomes ABC and now this is compared against ABC.&lt;br /&gt;&lt;br /&gt;Method 4:&lt;br /&gt;Another version conceived from Method 3&lt;br /&gt;&lt;br /&gt;select abc from abcCollection where replace(replace(abc,'ac',''),'b','') like '%ac%'&lt;br /&gt;&lt;br /&gt;Here is what it does:&lt;br /&gt;Take a string like this 'ACDFABBBCCA'&lt;br /&gt;When you replace 'AC' with empty string ( '' ) it becomes 'DFABBBCCA'&lt;br /&gt;Now replace 'B' with an empty string, it becomes 'DFACCA'&lt;br /&gt;Now this string is compared against 'AC'&lt;br /&gt;&lt;br /&gt;The following is the implementation of Method 1 in SQL Server 2005 using common table expressions. Its still a bad performer when compared to Methods 3 and 4. But here it is anyways :)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;with cte as&lt;br /&gt;(select abc,replace(abc,'bb','b') as d from abcCollection&lt;br /&gt;union all&lt;br /&gt;select abc, replace(d,'bb','b') from cte where d &lt;&gt; replace(d,'bb','b')&lt;br /&gt;)&lt;br /&gt;select abc from cte where d like '%abc%'&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3425640466761138561-1611416750189078811?l=webdeveloperscorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdeveloperscorner.blogspot.com/feeds/1611416750189078811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/02/pattern-matching-one-or-more-occurances.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/1611416750189078811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3425640466761138561/posts/default/1611416750189078811'/><link rel='alternate' type='text/html' href='http://webdeveloperscorner.blogspot.com/2008/02/pattern-matching-one-or-more-occurances.html' title='Pattern matching - One or more occurances of a character'/><author><name>Shibin Raj</name><uri>http://www.blogger.com/profile/07823163582851428440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
