<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>NeerajTripathi&#039;s Blog - Few technical approaches..</title>
	<atom:link href="http://neerajtripathi.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://neerajtripathi.wordpress.com</link>
	<description>A beam towards mystique technical concepts. [ASP.NET, SQL Server,C#, Windows and many more.]</description>
	<lastBuildDate>Wed, 13 Jan 2010 03:43:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='neerajtripathi.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/87a7590775b641e74f44b2de764ad4c5?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>NeerajTripathi&#039;s Blog - Few technical approaches..</title>
		<link>http://neerajtripathi.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://neerajtripathi.wordpress.com/osd.xml" title="NeerajTripathi&#039;s Blog - Few technical approaches.." />
	<atom:link rel='hub' href='http://neerajtripathi.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Basic Concept of Database Normalization</title>
		<link>http://neerajtripathi.wordpress.com/2010/01/12/normalization-of-data-base/</link>
		<comments>http://neerajtripathi.wordpress.com/2010/01/12/normalization-of-data-base/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 08:36:13 +0000</pubDate>
		<dc:creator>NeerajTripathi</dc:creator>
				<category><![CDATA[Database Concepts]]></category>

		<guid isPermaLink="false">http://neerajtripathi.wordpress.com/?p=73</guid>
		<description><![CDATA[&#8220;Normalization&#8221; one of the most common word related to data base. In fact this is a interesting topics in Relational database systems. Let me explain this using some new examples&#8230;. &#8220;NORMALIZATION IS A PROCESS BY WHICH WE LOOK FORWARD OVER TWO FACTS : 1. REDUNDANT DATA ELIMINATION. 2.DATA DEPENDENCIES WILL MAKE SENSE. WHICH HELPS TO [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=neerajtripathi.wordpress.com&amp;blog=8346670&amp;post=73&amp;subd=neerajtripathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8220;Normalization&#8221; one of the most common word related to data base. In fact this is a interesting topics in Relational database systems.  Let me explain this using some new examples&#8230;.</p>
<p><strong> &#8220;NORMALIZATION IS A PROCESS BY WHICH WE LOOK FORWARD OVER TWO FACTS : 1. REDUNDANT DATA ELIMINATION. 2.DATA DEPENDENCIES WILL MAKE SENSE. WHICH HELPS TO REDUCES THE DATABASE SPACE CONSUMPTION.&#8221;</strong> </p>
<p>Their are some series of guidelines are developed by the communities of database, known as first, second, third and fourth some how fifth normalization forms. But i am going to discuss only three of them :</p>
<p><strong>1. First Normal Form :</strong><br />
Their are only two root rules<br />
1.1 Their should be no duplicate columns.<br />
1.2 For each group of related data their should be separate tables, in which identify each row uniquely by a column or set of column.<br />
Example : This is EmployeeMaster as</p>
<table style="width:100%;background-color:#ededed;">
<tbody>
<tr>
<td style="width:20%;"><strong>Emp Code</strong></td>
<td style="width:20%;"><strong>Emp Name</strong></td>
<td style="width:20%;"><strong>Emp City One</strong></td>
<td style="width:20%;"><strong>Emp City Two</strong></td>
<td style="width:6%;"><strong>Basic Salary</strong></td>
<td style="width:7%;"><strong>Var Salary</strong></td>
<td style="width:7%;"><strong>Total Salary</strong></td>
</tr>
<tr>
<td style="width:20%;">EMP001</td>
<td style="width:20%;">Neeraj Tripathi</td>
<td style="width:20%;">Delhi</td>
<td style="width:20%;">Gurgaun</td>
<td style="width:6%;">10000</td>
<td style="width:7%;">5000</td>
<td style="width:7%;">15000</td>
</tr>
<tr>
<td style="width:20%;">EMP002</td>
<td style="width:20%;">Mayank Nath</td>
<td style="width:20%;">Mumbai</td>
<td style="width:20%;">Pune</td>
<td style="width:6%;">15000</td>
<td style="width:7%;">8500</td>
<td style="width:7%;">23500</td>
</tr>
</tbody>
</table>
<p>So apply the first normal form, Emp City will come in one column and Emp Name will break in two fiels:</p>
<table style="width:100%;background-color:#ededed;">
<tbody>
<tr>
<td style="width:20%;"><strong>Emp Code</strong></td>
<td style="width:20%;"><strong>Emp First Name</strong></td>
<td style="width:20%;"><strong>Emp Last Name</strong></td>
<td style="width:20%;"><strong>Emp City</strong></td>
<td style="width:6%;"><strong>Basic Salary</strong></td>
<td style="width:7%;"><strong>Var Salary</strong></td>
<td style="width:7%;"><strong>Total Salary</strong></td>
</tr>
<tr>
<td style="width:20%;">EMP001</td>
<td style="width:20%;">Neeraj</td>
<td style="width:20%;">Tripathi</td>
<td style="width:20%;">Delhi</td>
<td style="width:6%;">10000</td>
<td style="width:7%;">5000</td>
<td style="width:7%;">15000</td>
</tr>
<tr>
<td style="width:20%;">EMP001</td>
<td style="width:20%;">Neeraj</td>
<td style="width:20%;">Tripathi</td>
<td style="width:20%;">Gurgaun</td>
<td style="width:6%;">10000</td>
<td style="width:7%;">5000</td>
<td style="width:7%;">15000</td>
</tr>
<tr>
<td style="width:20%;">EMP002</td>
<td style="width:20%;">Mayank</td>
<td style="width:20%;">Nath</td>
<td style="width:20%;">Mumbai</td>
<td style="width:6%;">15000</td>
<td style="width:7%;">8500</td>
<td style="width:7%;">23500</td>
</tr>
<tr>
<td style="width:20%;">EMP002</td>
<td style="width:20%;">Mayank</td>
<td style="width:20%;">Nath</td>
<td style="width:20%;">Pune</td>
<td style="width:6%;">15000</td>
<td style="width:7%;">8500</td>
<td style="width:7%;">23500</td>
</tr>
</tbody>
</table>
<p>Now the given record set is in the first normal form.</p>
<p><strong>2. Second Normal Form :</strong><br />
This form state that after fulfilling all the condition of first normal form, their are two more conditions<br />
2.1 Place those data in separate tables which are not directly related to the primary key of that table.<br />
2.2 Create relationship between these tables using new table key (Foreign Key).</p>
<table style="width:100%;background-color:#ededed;">
<tbody>
<tr>
<td style="width:20%;"><strong>Emp Code</strong></td>
<td style="width:20%;"><strong>Emp First Name</strong></td>
<td style="width:20%;"><strong>Emp Last Name</strong></td>
<td style="width:20%;"><strong>Emp City Id</strong></td>
<td style="width:6%;"><strong>Basic Salary</strong></td>
<td style="width:7%;"><strong>Var Salary</strong></td>
<td style="width:7%;"><strong>Total Salary</strong></td>
</tr>
<tr>
<td style="width:20%;">EMP001</td>
<td style="width:20%;">Neeraj</td>
<td style="width:20%;">Tripathi</td>
<td style="width:20%;">1</td>
<td style="width:6%;">10000</td>
<td style="width:7%;">5000</td>
<td style="width:7%;">15000</td>
</tr>
<tr>
<td style="width:20%;">EMP001</td>
<td style="width:20%;">Neeraj</td>
<td style="width:20%;">Tripathi</td>
<td style="width:20%;">2</td>
<td style="width:6%;">10000</td>
<td style="width:7%;">5000</td>
<td style="width:7%;">15000</td>
</tr>
<tr>
<td style="width:20%;">EMP002</td>
<td style="width:20%;">Mayank</td>
<td style="width:20%;">Nath</td>
<td style="width:20%;">3</td>
<td style="width:6%;">15000</td>
<td style="width:7%;">8500</td>
<td style="width:7%;">23500</td>
</tr>
<tr>
<td style="width:20%;">EMP002</td>
<td style="width:20%;">Mayank</td>
<td style="width:20%;">Nath</td>
<td style="width:20%;">4</td>
<td style="width:6%;">15000</td>
<td style="width:7%;">8500</td>
<td style="width:7%;">23500</td>
</tr>
</tbody>
</table>
<p>And City Master become in scene</p>
<table style="width:40%;background-color:#ededed;">
<tbody>
<tr>
<td style="width:50%;"><strong>City Id</strong></td>
<td style="width:50%;"><strong>City Name</strong></td>
</tr>
<tr>
<td style="width:50%;">1</td>
<td style="width:50%;">Delhi</td>
</tr>
<tr>
<td style="width:50%;">2</td>
<td style="width:50%;">Gurgaun</td>
</tr>
<tr>
<td style="width:50%;">3</td>
<td style="width:50%;">Pune</td>
</tr>
<tr>
<td style="width:50%;">4</td>
<td style="width:50%;">Mumbai</td>
</tr>
</tbody>
</table>
<p>  That is now takes our database to a second normal form.</p>
<p><strong>3. Third Normal Form :</strong></p>
<p>So now meet all the fundamentals for IInd normal form and then </p>
<p>3.1 Remove all the non key fields which are depend on other non key fields.<br />
In our table &#8220;Total Salary&#8221; is a kind of field. So :</p>
<table style="width:100%;background-color:#ededed;">
<tbody>
<tr>
<td style="width:20%;"><strong>Emp Code</strong></td>
<td style="width:20%;"><strong>Emp First Name</strong></td>
<td style="width:20%;"><strong>Emp Last Name</strong></td>
<td style="width:20%;"><strong>Emp City Id</strong></td>
<td style="width:10%;"><strong>Basic Salary</strong></td>
<td style="width:10%;"><strong>Var Salary</strong></td>
</tr>
<tr>
<td style="width:20%;">EMP001</td>
<td style="width:20%;">Neeraj</td>
<td style="width:20%;">Tripathi</td>
<td style="width:20%;">1</td>
<td style="width:10%;">10000</td>
<td style="width:10%;">5000</td>
</tr>
<tr>
<td style="width:20%;">EMP001</td>
<td style="width:20%;">Neeraj</td>
<td style="width:20%;">Tripathi</td>
<td style="width:20%;">2</td>
<td style="width:10%;">10000</td>
<td style="width:10%;">5000</td>
</tr>
<tr>
<td style="width:20%;">EMP002</td>
<td style="width:20%;">Mayank</td>
<td style="width:20%;">Nath</td>
<td style="width:20%;">3</td>
<td style="width:10%;">15000</td>
<td style="width:10%;">8500</td>
</tr>
<tr>
<td style="width:20%;">EMP002</td>
<td style="width:20%;">Mayank</td>
<td style="width:20%;">Nath</td>
<td style="width:20%;">4</td>
<td style="width:10%;">15000</td>
<td style="width:10%;">8500</td>
</tr>
</tbody>
</table>
<p>So the &#8220;Total Salary&#8221; field is removed which can be easily get by &#8220;Basic Salary&#8221; + &#8220;Var Salary&#8221;.<br />
Ok Now our Database is normalized at the stage of Third normal form.</p>
<p>These are most applicable normal forms of database. I am not giving the idea about fourth and fifth normal forms. I apologies for that. But they have been rarely used in database normalization.</p>
<p>Now Happy reading. Cheers.<br />
Neeraj Tripathi</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/neerajtripathi.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/neerajtripathi.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/neerajtripathi.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/neerajtripathi.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/neerajtripathi.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/neerajtripathi.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/neerajtripathi.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/neerajtripathi.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/neerajtripathi.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/neerajtripathi.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/neerajtripathi.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/neerajtripathi.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/neerajtripathi.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/neerajtripathi.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=neerajtripathi.wordpress.com&amp;blog=8346670&amp;post=73&amp;subd=neerajtripathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://neerajtripathi.wordpress.com/2010/01/12/normalization-of-data-base/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>28.558297 77.171090</georss:point>
		<geo:lat>28.558297</geo:lat>
		<geo:long>77.171090</geo:long>
		<media:content url="http://0.gravatar.com/avatar/a6e16020251f9b3eac3fd6621f697fe7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">NeerajTripathi</media:title>
		</media:content>
	</item>
		<item>
		<title>Using JQuery with ASP.NET 3.5 and 4.0(Beta)</title>
		<link>http://neerajtripathi.wordpress.com/2009/12/16/using-jquery-with-asp-net-3-5-and-4-0beta/</link>
		<comments>http://neerajtripathi.wordpress.com/2009/12/16/using-jquery-with-asp-net-3-5-and-4-0beta/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 07:14:42 +0000</pubDate>
		<dc:creator>NeerajTripathi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://neerajtripathi.wordpress.com/?p=68</guid>
		<description><![CDATA[jQuery WHAT IS THIS &#8230;.? A JavaScript library very light, CSS3 compliant and supports most of the browsers. This framework of jQuery is handles DOM manipulations, CSS, AJAX, Events and Animations. Download latest version of jQuery from the jQuery Site. &#8230;&#8230;&#8230;. Still Working. Apologies for inconvenience.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=neerajtripathi.wordpress.com&amp;blog=8346670&amp;post=68&amp;subd=neerajtripathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>jQuery WHAT IS THIS &#8230;.?</strong><br />
A JavaScript library very light, CSS3 compliant and supports most of the browsers. This framework of jQuery is handles DOM manipulations, CSS, AJAX, Events and Animations.<br />
Download latest version of jQuery from the <a href="http://jquery.com">jQuery Site</a>.</p>
<p>&#8230;&#8230;&#8230;. Still Working. Apologies for inconvenience. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/neerajtripathi.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/neerajtripathi.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/neerajtripathi.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/neerajtripathi.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/neerajtripathi.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/neerajtripathi.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/neerajtripathi.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/neerajtripathi.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/neerajtripathi.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/neerajtripathi.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/neerajtripathi.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/neerajtripathi.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/neerajtripathi.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/neerajtripathi.wordpress.com/68/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=neerajtripathi.wordpress.com&amp;blog=8346670&amp;post=68&amp;subd=neerajtripathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://neerajtripathi.wordpress.com/2009/12/16/using-jquery-with-asp-net-3-5-and-4-0beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>28.558379 77.170307</georss:point>
		<geo:lat>28.558379</geo:lat>
		<geo:long>77.170307</geo:long>
		<media:content url="http://0.gravatar.com/avatar/a6e16020251f9b3eac3fd6621f697fe7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">NeerajTripathi</media:title>
		</media:content>
	</item>
		<item>
		<title>User Defined Functions in sql server 2005 ( UDF)</title>
		<link>http://neerajtripathi.wordpress.com/2009/12/15/user-defined-functions-in-sql-server-2005-udf/</link>
		<comments>http://neerajtripathi.wordpress.com/2009/12/15/user-defined-functions-in-sql-server-2005-udf/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 05:54:19 +0000</pubDate>
		<dc:creator>NeerajTripathi</dc:creator>
				<category><![CDATA[SQL Server Concepts]]></category>

		<guid isPermaLink="false">http://neerajtripathi.wordpress.com/?p=52</guid>
		<description><![CDATA[When one or more Transact-SQL statements are encapsulate with a subroutines called User Defined Functions. There must be unique Name of Each fully qualified UDF&#8217;s. Few Initialization * Create Function statement : Use : CREATE FUNCTION: * Modified Function statement : Use : ALTER FUNCTION * Removed Function statement : Use : DROP FUNCTION statement. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=neerajtripathi.wordpress.com&amp;blog=8346670&amp;post=52&amp;subd=neerajtripathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>
When one or more Transact-SQL statements are encapsulate with a subroutines called User Defined Functions. There must be unique Name of Each fully qualified UDF&#8217;s.<br />
Few Initialization<br />
  * Create Function statement : Use : CREATE FUNCTION:<br />
  * Modified Function statement : Use : ALTER FUNCTION<br />
  * Removed Function statement : Use : DROP FUNCTION statement.<br />
  * Users other than the owner must be granted appropriate permissions on a function before they can use it in a Transact-SQL statement.<br />
  * UDF have one or more the oneInput parameters ( Max No is 1024).<br />
  * Do Not Support OUTPUT Parameters.<br />
  * For Default Value use DEFAULT keyword. ( In SP&#8217;s Omitting the parameter mean Default.)</p>
<p><strong>Kind Of UDF&#8217;s :</strong><br />
<strong>1. Scaler Functions &#8211; </strong> Return a single data value , defined in return clause.<br />
Usable Data Types: Including bigint and sql_variant all scaler data type can be used.<br />
Unusable Data Types : Timestamp , table , cursor and User Defind Data Type they are not supported.<br />
Return support Data Types : Excluding text, ntext, Table, Cursor, timestamp and image.<br />
<strong>1. Table Valued Functions &#8211; </strong> These user defined functions return tables data type.<br />
<strong> 1.1</strong> Inline Table Valued Function having no table body, is the result set of a single select statement.<br />
    * The RETURNS clause contains only the keyword table.<br />
    * You do not have to define the format of a return variable because it is set by the format of the result set of the SELECT statement in the RETURN clause.<br />
    * There is no function_body delimited by BEGIN and END.<br />
    * The RETURN clause contains a single SELECT statement in parentheses. The result set of the SELECT statement forms the table returned by the function.<br />
    * The table-valued function accepts only constants or @local_variable arguments.<br />
Example :<br />
CREATE FUNCTION udfUserNameOfARegion<br />
                 ( @RegionIDPara integer(25) )<br />
RETURNS table<br />
AS<br />
RETURN (<br />
        SELECT CustomerID, CompanyName FROM dbo.UserMaster WHERE RegionID = @RegionIDPara<br />
       )<br />
GO</p>
<p>Now compile the the function and then try to access the result by function&#8230;<br />
  SELECT * FROM udfUserNameOfARegion(&#8217;10015&#8242;)<br />
well you may get the desired result.</p>
<p><strong> 1.2</strong> Multi-statement table-valued function, the function body, defined in a BEGIN&#8230;END block, contains the some TRANSACT-SQL statements that build and insert rows into the temp table and lastly that will be returned.<br />
  * UDF that return a table may be a powerful alternatives to views.<br />
  * They can be used where table or view expressions are allowed in Transact-SQL queries,While views are limited to a single SELECT statement and  more user-defined functions can contain additional statements that allow more powerful logic than is possible in views.<br />
  * Also can replace stored procedures that return a single result set. Because the table returned by a user-defined function can be referenced in the FROM clause of a Transact-SQL statement, but stored procedures that return result sets cannot.<br />
Example : SELECT * FROM tab_1 AS T1 INNER JOIN dbo.udf_temp(&#8216;para&#8217;) AS T2  ON T1.fieldOne = T2.fieldOne.<br />
  * The RETURNS clause defines a local return variable name for the table returned by the function. The RETURNS clause also defines the format of the table. The scope of the local return variable name is local within the function.<br />
  * The Transact-SQL statements in the function body build and insert rows into the return variable defined by the RETURNS clause.<br />
  * When a RETURN statement is executed, the rows inserted into the variable are returned as the tabular output of the function. </p>
<p>CREATE FUNCTION udfReturnUserName( @TotalSalary money )<br />
RETURNS @UserHaveHighPkgTab TABLE<br />
   (<br />
    UserID     int,<br />
    UserName   nvarchar(50),<br />
    UserCreationDate   datetime,<br />
    TotalSalary       money<br />
   )<br />
AS<br />
BEGIN<br />
   INSERT @UserHaveHighPkgTab<br />
        SELECT S.UserID, S.UserName, O.UserCreationDate , O.TotalSalary<br />
        FROM UserMaster AS UM INNER JOIN UserDetails AS UD<br />
              ON UM.UserID = UD.UserID<br />
        WHERE UD.Total &gt; @TotalSalary<br />
   RETURN<br />
END</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/neerajtripathi.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/neerajtripathi.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/neerajtripathi.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/neerajtripathi.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/neerajtripathi.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/neerajtripathi.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/neerajtripathi.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/neerajtripathi.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/neerajtripathi.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/neerajtripathi.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/neerajtripathi.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/neerajtripathi.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/neerajtripathi.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/neerajtripathi.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=neerajtripathi.wordpress.com&amp;blog=8346670&amp;post=52&amp;subd=neerajtripathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://neerajtripathi.wordpress.com/2009/12/15/user-defined-functions-in-sql-server-2005-udf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>28.558379 77.170307</georss:point>
		<geo:lat>28.558379</geo:lat>
		<geo:long>77.170307</geo:long>
		<media:content url="http://0.gravatar.com/avatar/a6e16020251f9b3eac3fd6621f697fe7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">NeerajTripathi</media:title>
		</media:content>
	</item>
		<item>
		<title>Tricks And Tips For SQL Optimization &#8211; SQL Server</title>
		<link>http://neerajtripathi.wordpress.com/2009/12/08/tricks-and-tips-for-sql-optimization/</link>
		<comments>http://neerajtripathi.wordpress.com/2009/12/08/tricks-and-tips-for-sql-optimization/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 10:01:00 +0000</pubDate>
		<dc:creator>NeerajTripathi</dc:creator>
				<category><![CDATA[SQL Server Concepts]]></category>

		<guid isPermaLink="false">http://neerajtripathi.wordpress.com/2009/12/08/tricks-and-tips-for-sql-optimization</guid>
		<description><![CDATA[• Always try to avoid using the DISTINCT clause, as for as possible. Because using the DISTINCT clause will result in some performance issue, use this clause only when it is necessary. • Attempt to avoid the HAVING clause possibly. The HAVING clause is used to restrict the output returned by the GROUP BY clause. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=neerajtripathi.wordpress.com&amp;blog=8346670&amp;post=16&amp;subd=neerajtripathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>• Always try to avoid using the DISTINCT clause, as for as possible.<br />
Because using the DISTINCT clause will result in some performance<br />
issue, use this clause only when it is necessary.</p>
<p>• Attempt to avoid the HAVING clause possibly. The HAVING clause is used to restrict the output returned by the GROUP BY clause. When we use GROUP BY with the HAVING clause, the GROUP BY clause divides the rows into sets of grouped rows and aggregates their values, and then the HAVING clause eliminates undesired aggregated groups.</p>
<p>• If you need to return the total table&#8217;s row count, you can use alternative way instead of SELECT COUNT(*) statement. Because SELECT COUNT(*) statement make a full table scan to return the total table&#8217;s row count, it can take very many time for the large table. You can use <span style="font-weight:bold;">sysindexes</span> system table, to determine the total row count. There is ROWS column in the sysindexes table. This column contains the total<br />
row count for each table in your database. So, you can use</p>
<p>SELECT rows FROM sysindexes WHERE id = OBJECT_ID(&#8216;table_name&#8217;) AND indid &lt; 2</p>
<p>• Always SET <span style="font-weight:bold;">NOCOUNT</span> ON statement into your stored procedures to stop the message indicating the number of rows affected by a T-SQL statement. This can reduce network traffic, because your client will not receive the message indicating the number of rows affected by a T-SQL statement.</p>
<p>• We could prefer to use views and stored procedures instead of heavy-duty queries. This can reduce network traffic, because your client will send to server only stored procedure or view name (perhaps with some parameters) instead of large heavy-duty queries text. This can be used to facilitate permission management also, because you can restrict user access to table columns they should not see.</p>
<p>• Try to use constraints instead of triggers, whenever possible. Constraints are much more efficient than triggers and can boost performance.</p>
<p>• Always use <span style="font-weight:bold;">Table Variables</span> instead of temporary tables. Table variables require less locking and logging resources than temporary tables, so table variables should be used whenever possible. The table variables are available in SQL Server 2000 only.</p>
<p>• Try to use UNION ALL statement instead of UNION as possible. Because UNION ALL statement does not look for duplicate rows, whether or not they exist, So UNION ALL is fast.</p>
<p>• Try to avoid using SQL Server cursors, whenever possible. SQL Server cursors can result in some performance degradation in comparison with select statements.</p>
<p>• Use the select statements with TOP keyword or the SET ROWCOUNT statement, if you need to return only the first n rows. This can improve performance of your queries and traffic between the server and the clients.</p>
<p>Few Index Optimization tips</p>
<p>• Keep your indexes as narrow as possible. This reduces the size of<br />
the index and reduces the number of reads required to read the index.</p>
<p>• Attempt to create indexes on columns that have integer values rather than character values.</p>
<p>• Create surrogate integer primary key (identity for example) if your table will not have many insert operations.</p>
<p>• The number of indexes should not be very much Because Every index increases the time in takes to perform INSERTS, UPDATES and DELETES. Try to use maximum 3-5 indexes on one table, not more.<br />
If you have read-only table, then the number of indexes may be increased.</p>
<p>• See if you want to join several tables, try to create <span style="font-weight:bold;">surrogate integer keys</span> for this purpose and create indexes on their columns.</p>
<p>For Surrogate key Vs. Natural Key <a href="http://decipherinfosys.wordpress.com/2007/02/01/surrogate-keys-vs-natural-keys-for-primary-key/" target="_blank">Refer</a></p>
<p>• In case of a composite (multi-column) index, the order of the columns in the key are very important. Try to order the columns in the key as to enhance selectivity, with the most selective columns to the leftmost of the key.</p>
<p>• <span style="font-weight:bold;">Clustered indexes</span> are more preferable than nonclustered, if you need to select by a range of values or you need to sort results set with GROUP BY or ORDER BY.</p>
<p>• If your application will be performing the same query over and over on the same table, consider creating a <span style="font-weight:bold;">covering index</span> on the table.</p>
<p>• You can use the SQL Server Profiler Create Trace Wizard with &#8220;Identify Scans of Large Tables&#8221; trace to determine which tables in your database may need indexes. This trace will show which tables are being scanned by queries instead of using an index.</p>
<p>• You can use sp_MSforeachtable undocumented stored procedure to rebuild all indexes in your database.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/neerajtripathi.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/neerajtripathi.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/neerajtripathi.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/neerajtripathi.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/neerajtripathi.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/neerajtripathi.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/neerajtripathi.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/neerajtripathi.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/neerajtripathi.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/neerajtripathi.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/neerajtripathi.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/neerajtripathi.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/neerajtripathi.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/neerajtripathi.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=neerajtripathi.wordpress.com&amp;blog=8346670&amp;post=16&amp;subd=neerajtripathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://neerajtripathi.wordpress.com/2009/12/08/tricks-and-tips-for-sql-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>28.558379 77.170307</georss:point>
		<geo:lat>28.558379</geo:lat>
		<geo:long>77.170307</geo:long>
		<media:content url="http://0.gravatar.com/avatar/a6e16020251f9b3eac3fd6621f697fe7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">NeerajTripathi</media:title>
		</media:content>
	</item>
		<item>
		<title>Some Tricky SQL Query / Based on SQL Server 2005 ( PART Ist )</title>
		<link>http://neerajtripathi.wordpress.com/2009/12/08/some-tricky-sql-query-based-on-sql-server-2005-part-ist/</link>
		<comments>http://neerajtripathi.wordpress.com/2009/12/08/some-tricky-sql-query-based-on-sql-server-2005-part-ist/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 06:46:00 +0000</pubDate>
		<dc:creator>NeerajTripathi</dc:creator>
				<category><![CDATA[SQL Server Concepts]]></category>

		<guid isPermaLink="false">http://neerajtripathi.wordpress.com/2009/12/08/some-tricky-sql-query-based-on-sql-server-2005-part-ist</guid>
		<description><![CDATA[Hello friend, This is a series article, i would like to recommend you, go through other parts as on first, for boosting your tricks in SQL server queries and concepts : 1. Duplicate record deletion : You have a CountryMaster Table having fields as CountyName, CountryID SET ROWCOUNT 1 DELETE CountryMaster FROM CountryMaster a WHERE [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=neerajtripathi.wordpress.com&amp;blog=8346670&amp;post=15&amp;subd=neerajtripathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>Hello friend,<br />
This is a series article, i would like to recommend you, go through other parts as on first, for boosting your tricks in SQL server queries and concepts :</p>
<p>1. Duplicate record deletion : You have a CountryMaster Table having fields as CountyName, CountryID</p>
<p>SET ROWCOUNT 1<br />
DELETE CountryMaster<br />
FROM CountryMaster a<br />
WHERE (SELECT COUNT(*) FROM CountryMaster b WHERE b.CountryName = a.CountryName) &gt; 1<br />
WHILE @@rowcount &gt; 0<br />
DELETE CountryMaster<br />
FROM CountryMaster a<br />
WHERE (SELECT COUNT(*) FROM CountryMaster b WHERE b.CountryName = a.CountryName) &gt; 1<br />
SET ROWCOUNT 0</p>
<p>OR</p>
<p>DELETE FROM [TestNeeraj].[dbo].[CountryMaster] WHERE CountryId NOT IN<br />
(SELECT MAX(CountryID) FROM CountryMaster GROUP BY CountryName)</p>
<p>NOTE : SET <span style="font-weight:bold;">ROWCOUNT</span> statement simply limits the number of records returned to the client during a single connection and This can not be used in UDF.</p>
<p>2. Using ROLLUP For Total And Sub Totals in fetched records : Having Table WorkOrderRouting and fields as OperationSequence , WorkOrderRouting</p>
<p>SELECT CASE WHEN OperationSequence IS NULL THEN 9999999 ELSE OperationSequence END SEQ, SUM(ActualResourceHrs) AS HRS FROM [WorkOrderRouting]<br />
GROUP BY OperationSequence WITH ROLLUP ORDER BY OperationSequence</p>
<p>3. How to find 2nd highest salary</p>
<p>SELECT TOP 1 salary FROM (SELECT DISTINCT TOP 2 salary<br />
FROM employee ORDER BY salary DESC) a ORDER BY salary</p>
<p>4. Select First day of month :</p>
<p>SELECT DATENAME(dw, DATEADD(dd, &#8211; DATEPART(dd, GETDATE()) + 1, GETDATE())) AS FirstDay</p>
<p>For DATEPART abbreviations<br />
<a href="http://msdn.microsoft.com/en-us/library/ms174420(SQL.90).aspx" target="_blank">you may refer</a></p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/neerajtripathi.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/neerajtripathi.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/neerajtripathi.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/neerajtripathi.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/neerajtripathi.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/neerajtripathi.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/neerajtripathi.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/neerajtripathi.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/neerajtripathi.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/neerajtripathi.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/neerajtripathi.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/neerajtripathi.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/neerajtripathi.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/neerajtripathi.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=neerajtripathi.wordpress.com&amp;blog=8346670&amp;post=15&amp;subd=neerajtripathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://neerajtripathi.wordpress.com/2009/12/08/some-tricky-sql-query-based-on-sql-server-2005-part-ist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a6e16020251f9b3eac3fd6621f697fe7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">NeerajTripathi</media:title>
		</media:content>
	</item>
	</channel>
</rss>
