<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
	<channel>
		<title>Patel&#039;s Lab : Chirag Patel&#039;s Lab</title>
		<link>http://patelslab.yourliveblog.com/Patel-s-Lab-b1.htm</link>
		<description>Enjoy Coding</description>
		<lastBuildDate>Sun, 14 Mar 2010 16:48:27 GMT</lastBuildDate>
		<ttl>10</ttl>
		<image>
			<title>Patel&#039;s Lab : Chirag Patel&#039;s Lab</title>
			<url></url>
			<link>http://patelslab.yourliveblog.com/Patel-s-Lab-b1.htm</link>
		</image>
	<item>
		<title>Call SSIS From Stored procedure</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2008-06-24T09:31:11Z</pubDate>
		<description>&lt;h2&gt;Introduction&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;SSIS (SQL Server Integration Services) packages, are the server side packages, which will be called from the server, that may be achieved by creating web service. But sometimes we want to pass some excel, or flat files in SSIS package, and this file must be transferred to server to use in SSIS package. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;So sometimes there may be some security issues when the web service will be restricted to allow using resources on the server. So we have to use some other way, not web service, to call SSIS. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Background&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;This article assumes that you are familiar with creating SSIS packages and how to add variables into package and how to call SSIS package to use in code. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Using the code&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;This article has two attached files &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;1) &lt;strong&gt;enablexp_cmdScript.sql&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;2) &lt;strong&gt;ssisfromsql.sql&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;First, i will tell the other way to call SSIS package other tahn using &amp;quot;web service&amp;quot;. We can use Stored procedure to call SSIS package. How? &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;There is one System Stored Procedure in SQL Server 2005 called &amp;quot;xp_cmdshell&amp;quot; which will be set to &amp;quot;False&amp;quot;, means this sp is not active by default at the time of SQL Server Installation. We have to manually enable this SP to use. This can be done two way, either by running some script, (which is given in &lt;strong&gt;enablexp_cmdscript.sql&lt;/strong&gt; file) or by using &amp;quot;SQL Server surface Area configuration&amp;quot; tool which will be installed with SQL Server 2005. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;xp_cmdshell&lt;/strong&gt; : &amp;quot;xp_cmdshell&amp;quot; is an extended stored procedure provided by Microsoft and stored in the master database. This procedure allows you to issue operating system commands directly to the Windows command shell via T-SQL code. If needed the output of these commands will be returned to the calling routine. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Start the Surface Area congifuration tool from your SQL server installation in Program Menu, it will look like this, &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For the Image and complated Article please see my post at CodeProject at here,&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.codeproject.com/KB/database/Call_SSIS_from_SP.aspx&quot;&gt;http://www.codeproject.com/KB/database/Call_SSIS_from_SP.aspx&lt;/a&gt; &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Now, click on the &amp;quot;Surface Area configuration for Features&amp;quot; link and you will see the following screen, from the Left side meny select your instance name and click on &amp;quot;xp_cmdshell&amp;quot; option under it, just like this, &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For the Image and complated Article please see my post at CodeProject at here,&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.codeproject.com/KB/database/Call_SSIS_from_SP.aspx&quot;&gt;http://www.codeproject.com/KB/database/Call_SSIS_from_SP.aspx&lt;/a&gt; &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;just enable the xp_cmdshell option, the xp_cmdsheel SP will be enabled after you restart the SQL server services.&lt;br /&gt;&lt;br /&gt;If you do not want to do like this, just run the following Script lines in you selected instance in SQL Server, &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;font face=&quot;courier new,courier&quot; size=&quot;2&quot;&gt;USE master &lt;br /&gt;GO &lt;br /&gt;EXEC sp_configure &#039;show advanced options&#039;, 1 &lt;br /&gt;GO &lt;br /&gt;RECONFIGURE WITH OVERRIDE &lt;br /&gt;GO &lt;br /&gt;EXEC sp_configure &#039;xp_cmdshell&#039;, 1 &lt;br /&gt;GO &lt;br /&gt;RECONFIGURE WITH OVERRIDE &lt;br /&gt;GO &lt;br /&gt;EXEC sp_configure &#039;show advanced options&#039;, 0 &lt;br /&gt;GO&lt;/font&gt;  &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Now, we are ready to use &amp;quot;xp_cmdshell&amp;quot; stored procedure to call our SSIS package. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Now, i have created one SSIS package called &amp;quot;&lt;strong&gt;ImportItemFile&lt;/strong&gt;&amp;quot;, what it will do, it will fetche the Excel file from the provided location on Server, and will load all the items from excel file to Item table in database. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Varialbes&lt;/strong&gt; i have to pass are: FileName, CreatedBy, ContractDbConnectionString, BatchID, SupplierID &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Here, i have used two special command one is &amp;quot;xp_cmdshell&amp;quot; and second is &amp;quot;dtexec&amp;quot;.&lt;br /&gt;&lt;br /&gt;now what is &amp;quot;dtexec&amp;quot; command,&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;dtexec :&lt;/strong&gt; The &lt;strong&gt;dtexec&lt;/strong&gt; command prompt utility is used to configure and execute SQL Server 2005 Integration Services (SSIS) packages. The &lt;strong&gt;dtexec&lt;/strong&gt; utility provides access to all the package configuration and execution features, such as connections, properties, variables, logging, and progress indicators. The &lt;strong&gt;dtexec&lt;/strong&gt; utility lets you load packages from three sources: a Microsoft SQL Server database, the SSIS service, and the file system.&lt;br /&gt;&lt;br /&gt;(Reference from: &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms162810.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms162810.aspx&lt;/a&gt;) &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Now the Script i will create here, is dynamic SQL, means we can use it to call any SSIS pacakges, just we have to pass necessary varibales. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font face=&quot;courier new,courier&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;declare&lt;/span&gt; @ssisstr &lt;span class=&quot;code-keyword&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;code-digit&quot;&gt;8000&lt;/span&gt;), @packagename &lt;span class=&quot;code-keyword&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;code-digit&quot;&gt;200&lt;/span&gt;),@servername &lt;span class=&quot;code-keyword&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;code-digit&quot;&gt;100&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;declare&lt;/span&gt; @params &lt;span class=&quot;code-keyword&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;code-digit&quot;&gt;8000&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-comment&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt;--my package name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;set&lt;/span&gt; @packagename = &lt;span class=&quot;code-string&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;code-string&quot;&gt;ImportItemFile&#039;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-comment&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt;--my server name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;set&lt;/span&gt; @servername = &lt;span class=&quot;code-string&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;code-string&quot;&gt;myserversql2k5&#039;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-comment&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt;-- please make this line in single line, i have made this line in multiline &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-comment&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt;--due to article format.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-comment&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt;--package variables, which we are passing in SSIS Package.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;set&lt;/span&gt; @params = &lt;span class=&quot;code-string&quot;&gt;&#039;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span class=&quot;code-string&quot;&gt;&lt;font face=&quot;courier new,courier&quot; size=&quot;2&quot;&gt;/set package.variables[FileName].Value;&amp;quot;&amp;quot;&lt;/font&gt;&lt;a href=&quot;http://www.codeproject.com/KB/database/%22file://127.0.0.1/Common%20%20%20%20%20%20%20%20%20%20%20/SSIS/NewItem.xls/%22&quot;&gt;&lt;font face=&quot;courier new,courier&quot; size=&quot;2&quot;&gt;127.0.0.1Common&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SSISNewItem.xls&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;courier new,courier&quot; size=&quot;2&quot;&gt;&amp;quot;&amp;quot; /set package.variables[CreatedBy].Value;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;&amp;quot;Chirag&amp;quot;&amp;quot; /set package.variables[ContractDbConnectionString].Value;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;&amp;quot;Data Source=myserverSQL2K5;User ID=sa;Password=sapass;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Initial Catalog=Items;Provider=SQLNCLI.1;Persist Security Info=True;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Auto Translate=False;&amp;quot;&amp;quot; /set package.variables[BatchID].Value;&amp;quot;&amp;quot;1&amp;quot;&amp;quot; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /set package.variables[SupplierID].Value;&amp;quot;&amp;quot;22334&amp;quot;&amp;quot;&#039;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font face=&quot;courier new,courier&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span class=&quot;code-comment&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt;--now making &amp;quot;dtexec&amp;quot; SQL from dynamic values&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;set&lt;/span&gt; @ssisstr = &lt;span class=&quot;code-string&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;code-string&quot;&gt;dtexec /sq &#039;&lt;/span&gt; + @packagename + &lt;span class=&quot;code-string&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;code-string&quot;&gt; /ser &#039;&lt;/span&gt; + @servername + &lt;span class=&quot;code-string&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;code-string&quot;&gt; &#039;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;set&lt;/span&gt; @ssisstr = @ssisstr + @params&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-comment&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt;---print line for varification &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-comment&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt;print @ssisstr&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-comment&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt;--&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-comment&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt;--now execute dynamic SQL by using EXEC. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;DECLARE&lt;/span&gt; @returncode &lt;span class=&quot;code-keyword&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;EXEC&lt;/span&gt; @returncode = xp_cmdshell @ssisstr&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;select&lt;/span&gt; @returncode&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;now we will see the variable passing structure of the &amp;quot;dtexec&amp;quot; command, &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre class=&quot;libCScode&quot;&gt;&lt;br /&gt;/SET packageDataFlowTask.Variables[User::MyVariable].Value;newValue&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class=&quot;libCScode&quot;&gt;&lt;br /&gt;Now the @returncode variable will be returned by the &amp;quot;dtexec&amp;quot; command and it will be two record set, first will return the code from the following possibl value which will indicate the SSIS package status, and second table will describe all the processes happened during execution of the SSIS package. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;table border=&quot;1&quot; width=&quot;477&quot; style=&quot;width: 477px; height: 206px; background-color: #cccccc&quot;&gt;&lt;br /&gt;	&lt;tbody&gt;&lt;br /&gt;		&lt;tr&gt;&lt;br /&gt;			&lt;th&gt;Value &lt;/th&gt;&lt;th&gt;Description &lt;/th&gt;&lt;br /&gt;		&lt;/tr&gt;&lt;br /&gt;		&lt;tr&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			0 &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			The package executed successfully. &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;		&lt;/tr&gt;&lt;br /&gt;		&lt;tr&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			1 &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			The package failed. &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;		&lt;/tr&gt;&lt;br /&gt;		&lt;tr&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			3 &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			The package was canceled by the user. &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;		&lt;/tr&gt;&lt;br /&gt;		&lt;tr&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			4 &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			The utility was unable to locate the requested package. The package could not be found. &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;		&lt;/tr&gt;&lt;br /&gt;		&lt;tr&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			5 &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			The utility was unable to load the requested package. The package could not be loaded. &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;		&lt;/tr&gt;&lt;br /&gt;		&lt;tr&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			6 &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;			&lt;td&gt;&lt;br /&gt;			&lt;p&gt;&lt;br /&gt;			The utility encountered an internal error of syntactic or semantic errors in the command line. &lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;		&lt;/tr&gt;&lt;br /&gt;	&lt;/tbody&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;So, by this way we can call the SSIS package from the Stored Procedure by using &amp;quot;xp_cmdsjell&amp;quot; and &amp;quot;dtexec&amp;quot; command from the SQL Server. and we will never face the problems which we may get during calling of SSIS from Web service. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Resources&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&amp;quot;xp_cmdshell&amp;quot; and &amp;quot;dtexec&amp;quot; also can be used for many more functionality, following are the links for both command which will describe both in details for their syntax and usage. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;dtexec : &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms162810.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms162810.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;xp_cmdshell : &lt;a href=&quot;http://www.databasejournal.com/features/mssql/article.php/3372131&quot;&gt;http://www.databasejournal.com/features/mssql/article.php/3372131&lt;/a&gt; &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Call-SSIS-From-Stored-procedure-b1-p49910.htm</guid>
	</item>
	<item>
		<title>Useful Links</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-06T11:22:04Z</pubDate>
		<description>&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL Partitioning&lt;br /&gt;&lt;br /&gt;http://www.sqlskills.com/resources/Whitepapers/Partitioning%20in%20SQL%20Server%202005%20Beta%20II.htm&lt;br /&gt;&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Useful-Links-b1-p24.htm</guid>
	</item>
	<item>
		<title>Speed Optimization in ASP.NET 2.0 Web Applications</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-05T12:13:56Z</pubDate>
		<description>&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Use HTML controls&lt;br /&gt;whenever possible&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;HTML controls is lighter&lt;br /&gt;than server controls especially if you are using server controls with its&lt;br /&gt;default properties. Server controls generally is easier to use than HTML&lt;br /&gt;controls, and on the other side they are slower than HTML controls. So, it is&lt;br /&gt;recommended to use HTML controls whenever possible and avoid using unnecessary&lt;br /&gt;server controls.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Avoid round trips to&lt;br /&gt;server whenever possible&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Using server controls&lt;br /&gt;will extensively increase round trips to the server via their post back events&lt;br /&gt;which wastes a lot of time. You typically need to avoid these unnecessary round&lt;br /&gt;trips or post back events as possible. For example, validating user inputs can&lt;br /&gt;always (or at least in most cases) take place in the client side. There is no&lt;br /&gt;need to send these inputs to the server to check their validity. In general you&lt;br /&gt;should avoid code that causes a round trip to the server.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;The Page.IsPostBack&lt;br /&gt;Property&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;The &lt;em&gt;Page.IspostBack&lt;/em&gt;&lt;br /&gt;Boolean property indicates whether this page is loaded as a response to a round&lt;br /&gt;trip to the server, or it is being loaded for the first time. This property&lt;br /&gt;helps you to write the code needed for the first time the page is loaded, and&lt;br /&gt;avoiding running this same code each time the page is posted back. You can use&lt;br /&gt;this property efficiently in the page_load event. This event is executed each&lt;br /&gt;time a page is loaded, so you can use this property conditionally to avoid&lt;br /&gt;unnecessary re-running of certain code.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Server Control&#039;s&lt;br /&gt;AutoPostBack Property&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Always set this property&lt;br /&gt;to false except when you really need to turn it on. This property automatically&lt;br /&gt;post back to the server after some action takes place depending on the type of&lt;br /&gt;the control. For example, in the Text Control this property automatically &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Leave Buffering on&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;It is important to leave&lt;br /&gt;page buffering in its on state to improve your page speed, unless you have a&lt;br /&gt;serious reason to turn it off.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Server&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt; Controls&lt;br /&gt;View State&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Server control by&lt;br /&gt;default saves all the values of its properties between round trips, and this&lt;br /&gt;increases both page size and processing time which is of course an undesired&lt;br /&gt;behavior. Disable the server control view state whenever possible. For example,&lt;br /&gt;if you bind data to a server control each time the page is posted back, then it&lt;br /&gt;is useful to disable the control&#039;s view state property. This reduces page size&lt;br /&gt;and processing time.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Methods for&lt;br /&gt;redirection&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;There are many ways you&lt;br /&gt;can use to redirect a user from the current page to another one in the same&lt;br /&gt;application, however the most efficient methods to do this are: the &lt;em&gt;Server.Transfer&lt;/em&gt;&lt;br /&gt;method or cross-page posting.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Web Applications&lt;/h2&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;The following topics&lt;br /&gt;give you some tips about how to make an efficient web application:&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Precompilation&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;When an already deployed&lt;br /&gt;ASP.NET web application page is requested for the first time, that page needs&lt;br /&gt;to be compiled (by the server) before the user gets a response. The compiled&lt;br /&gt;page or code is then cached so that we need not to compile it again for the&lt;br /&gt;coming requests. It is clear that the first user gets a slow response than the&lt;br /&gt;following users. This scenario is repeated for each web page and code file&lt;br /&gt;within your web site.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;When using&lt;br /&gt;precompilation then the ASP.NET entire web application pages and code files&lt;br /&gt;will be compiled ahead. So, when a user requests a page from this web&lt;br /&gt;application he will get it in a reasonable response time whatever he is the&lt;br /&gt;first user or not.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Precompiling the entire&lt;br /&gt;web application before making it available to users provides faster response&lt;br /&gt;times. This is very useful on frequently updated large web applications.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Encoding&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;By default ASP.NET&lt;br /&gt;applications use UTF-8 encoding. If your application is using ASCII codes only,&lt;br /&gt;it is preferred to set your encoding to ASCII to improve your application&lt;br /&gt;performance.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Authentication&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;It is recommended to&lt;br /&gt;turn authentication off when you do not need it. The authentication mode for&lt;br /&gt;ASP.NET applications is windows mode. In many cases it is preferred to turn off&lt;br /&gt;the authentication in the &#039;machin.config&#039; file located on your server and to&lt;br /&gt;enable it only for applications that really need it.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Debug Mode&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Before deploying your&lt;br /&gt;web application you have to disable the debug mode. This makes your deployed&lt;br /&gt;application faster than before. You can disable or enable debug mode form&lt;br /&gt;within your application&#039;s &#039;web.config&#039; file under the &#039;system.web&#039; section as a&lt;br /&gt;property to the &#039;compilation&#039; item. You can set it to &#039;true&#039; or &#039;false&#039;.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Coding Practices&lt;/h2&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;The following topics&lt;br /&gt;give you guidelines to write efficient code:&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Page Size&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Web page with a large size&lt;br /&gt;consumes more bandwidth over the network during its transfer. Page size is&lt;br /&gt;affected by the numbers and types of controls it contains, and the number of&lt;br /&gt;images and data used to render the page. The larger the slower, this is the&lt;br /&gt;rule. Try to make your web pages small and as light as possible. This will&lt;br /&gt;improve response time.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Exception Handling&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;It is better for your&lt;br /&gt;application in terms of performance to detect in your code conditions that may&lt;br /&gt;cause exceptions instead of relying on catching exceptions and handling them.&lt;br /&gt;You should avoid common exceptions like null reference, dividing by zero ,&lt;br /&gt;and so on by checking them manually in your code.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;The following code gives&lt;br /&gt;you two examples: The first one uses exception handling and the second tests&lt;br /&gt;for a condition. Both examples produce the same result, but the performance of&lt;br /&gt;the first one suffers significantly.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;100%&quot; class=&quot;MsoNormalTable&quot; style=&quot;width: 100%&quot;&gt;&lt;br /&gt;	&lt;tbody&gt;&lt;br /&gt;		&lt;tr&gt;&lt;br /&gt;			&lt;td width=&quot;5%&quot; style=&quot;padding: 0.75pt; width: 5%&quot;&gt;&lt;br /&gt;			&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;			&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt; &lt;/span&gt;&lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;			&lt;td width=&quot;90%&quot; style=&quot;border: 1pt solid #cccccc; padding: 0.75pt; background: #ffffcc none repeat scroll 0% 50%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial&quot;&gt;&lt;br /&gt;			&lt;pre&gt;&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;    8&lt;/span&gt;         &lt;span class=&quot;cb1&quot;&gt;&#039; This is not recommended.&lt;/span&gt;&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;    9&lt;/span&gt;         &lt;span class=&quot;cb2&quot;&gt;Try&lt;/span&gt;&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;   10&lt;/span&gt;             Output = 100 / number&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;   11&lt;/span&gt;         &lt;span class=&quot;cb2&quot;&gt;Catch&lt;/span&gt; ex &lt;span class=&quot;cb2&quot;&gt;As&lt;/span&gt; Exception&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;   12&lt;/span&gt;             Output = 0&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;   13&lt;/span&gt;         &lt;span class=&quot;cb2&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;cb2&quot;&gt;Try&lt;/span&gt;&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;   14&lt;/span&gt; &lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;   15&lt;/span&gt;         &lt;span class=&quot;cb1&quot;&gt;&#039; This is preferred.&lt;/span&gt;&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;   16&lt;/span&gt;         &lt;span class=&quot;cb2&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;cb2&quot;&gt;Not&lt;/span&gt; (number = 0) &lt;span class=&quot;cb2&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;   17&lt;/span&gt;             Output = 100 / number&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;   18&lt;/span&gt;         &lt;span class=&quot;cb2&quot;&gt;Else&lt;/span&gt;&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;   19&lt;/span&gt;             Output = 0&lt;br /&gt;			&lt;span class=&quot;cln&quot;&gt;   20&lt;/span&gt;         &lt;span class=&quot;cb2&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;cb2&quot;&gt;If&lt;/span&gt;&lt;br /&gt;			&lt;/pre&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;			&lt;td width=&quot;5%&quot; style=&quot;padding: 0.75pt; width: 5%&quot;&gt;&lt;br /&gt;			&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;			&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt; &lt;/span&gt;&lt;br /&gt;			&lt;/p&gt;&lt;br /&gt;			&lt;/td&gt;&lt;br /&gt;		&lt;/tr&gt;&lt;br /&gt;	&lt;/tbody&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Garbage Collector&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;ASP.NET provides&lt;br /&gt;automatic garbage collection and memory management. The garbage collector&#039;s&lt;br /&gt;main task is to allocate and release memory for your application. There are&lt;br /&gt;some tips you can take care of when you writing your application&#039;s code to make&lt;br /&gt;the garbage collector works for your benefit:&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Avoid using objects with&lt;br /&gt;a Finalize sub as possible and avoid freeing resources in Finalize functions.&lt;br /&gt;&lt;br /&gt;Avoid allocating too much memory per web page because the garbage collector&lt;br /&gt;will have to do more work for each request and this increases CPU utilization&lt;br /&gt;(not to mention you can go out of memories in larger web applications) &lt;br /&gt;&lt;br /&gt;Avoid having unnecessary pointers to objects because this makes these objects&lt;br /&gt;alive until you free them yourself within your code not in an automatic way.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Use Try / Finally&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;If you are to use&lt;br /&gt;exceptions anyway, then always use a try / finally block to handle your&lt;br /&gt;exceptions. In the finally section you can close your resources if an exception&lt;br /&gt;occurred or not. If an exception occurs, then the finally section will clean&lt;br /&gt;up your resources and frees them up.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;String Concatenation&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;articletext&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;Many string&lt;br /&gt;concatenations are time consuming operations. So, if you want to concatenate&lt;br /&gt;many strings such as to dynamically build some HTML or XML strings then use the&lt;br /&gt;&lt;em&gt;System.Text.StringBuilder&lt;/em&gt; object instead of &lt;em&gt;system.string&lt;/em&gt; data&lt;br /&gt;type. The append method of the StringBuilder class is more efficient than&lt;br /&gt;concatenation.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Speed-Optimization-in-ASPNET-20-Web-Applications-b1-p23.htm</guid>
	</item>
	<item>
		<title>Google Checkout</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-05T12:04:28Z</pubDate>
		<description>&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;Google checkout enables us to process customer orders in two&lt;br /&gt;ways,&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;Option 1: Integrate only your shopping cart &lt;/strong&gt;(easier:&lt;br /&gt;requires only a working knowledge of HTML) &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Send shopping carts to Google&lt;br /&gt;	using HTML code you add to your site. &lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Process orders through the Google Checkout &lt;font color=&quot;#0000ff&quot;&gt;&lt;a href=&quot;http://checkout.google.com/support/sell/bin/answer.py?answer=42874&quot;&gt;Merchant&lt;br /&gt;	Center&lt;/a&gt;.&lt;/font&gt; &lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Integrate using the&lt;font color=&quot;#0000ff&quot;&gt; &lt;a href=&quot;http://code.google.com/apis/checkout/developer/google_checkout_html_api.html&quot;&gt;HTML&lt;br /&gt;	API Developer&#039;s Guide&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Option 2: Integrate your cart AND order processing system&lt;/strong&gt; (more complex:&lt;br /&gt;requires API programming &lt;font color=&quot;#0000ff&quot;&gt;&lt;a href=&quot;http://checkout.google.com/support/sell/bin/answer.py?answer=38882&quot;&gt;experience&lt;/a&gt;&lt;/font&gt;)&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Send shopping carts to Google&lt;br /&gt;	via an XML-based API. &lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Process orders through your&lt;br /&gt;	existing order processing system. &lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Integrate using the &lt;font color=&quot;#0000ff&quot;&gt;&lt;a href=&quot;http://code.google.com/apis/checkout/developer/index.html&quot;&gt;XML API&lt;br /&gt;	Developer&#039;s Guide&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;In option 1, we have to build one form in html with hidden&lt;br /&gt;fields containing necessary information for Google Checkout process. Orders&lt;br /&gt;will then be processed through Google Checkout Merchant Account.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;While in Option 2, we can integrate our existing order&lt;br /&gt;processing system with the Google checkout with XML API.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;In Option 1, customer will have to log in into his customer&lt;br /&gt;Account for Google checkout, and then he can view his purchase information&lt;br /&gt;which is sent by us (Our site) with hidden fields, in HTML form. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;span&gt;            &lt;/span&gt;Same way, we&lt;br /&gt;can (Site Administrator) analyze the order information and can do operations&lt;br /&gt;like charging the customer for his order.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;Getting Started Doc for Google Checkout is,&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;background-color: #ffffff&quot; class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;font color=&quot;#0000ff&quot;&gt;&lt;a href=&quot;http://code.google.com/apis/checkout/developer/google_checkout_html_api.html&quot;&gt;Google&lt;br /&gt;Checkout&lt;/a&gt;&lt;/font&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Google-Checkout-b1-p22.htm</guid>
	</item>
	<item>
		<title>SQL Interview questions</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-05T11:59:14Z</pubDate>
		<description>&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is RDBMS?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Relational Data Base Management Systems (RDBMS) are database management systems&lt;br /&gt;that maintain data records and indices in tables. Relationships may be created&lt;br /&gt;and maintained across and among the data and tables. In a relational database,&lt;br /&gt;relationships between data items are expressed by means of tables.&lt;br /&gt;Interdependencies among these tables are expressed by data values rather than&lt;br /&gt;by pointers. This allows a high degree of data independence. An RDBMS has the&lt;br /&gt;capability to recombine the data items from different files, providing powerful&lt;br /&gt;tools for data usage.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is normalization?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Database normalization is a data design and organization processes applied to&lt;br /&gt;data structures based on rules that help build relational databases. In&lt;br /&gt;relational database design, the process of organizing data to minimize&lt;br /&gt;redundancy. Normalization usually involves dividing a database into two or more&lt;br /&gt;tables and defining relationships between the tables. The objective is to&lt;br /&gt;isolate data so that additions, deletions, and modifications of a field can be&lt;br /&gt;made in just one table and then propagated through the rest of the database via&lt;br /&gt;the defined relationships.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What are different normalization forms?&lt;/strong&gt;&lt;/u&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;1NF: Eliminate Repeating Groups&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Make a separate table for each set of related attributes, and give each table a&lt;br /&gt;primary key. Each field contains at most one value from its attribute domain.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;2NF: Eliminate Redundant Data&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;If an attribute depends on only part of a multi-valued key, remove it to a&lt;br /&gt;separate table.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;3NF: Eliminate Columns Not Dependent On Key &lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;If attributes do not contribute to a description of the key, remove them to a&lt;br /&gt;separate table. All attributes must be directly dependent on the primary key&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;BCNF: Boyce-Codd Normal Form&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;If there are non-trivial dependencies between candidate key attributes,&lt;br /&gt;separate them out into distinct tables.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;4NF: Isolate Independent Multiple Relationships&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;No table may contain two or more 1:n or n:m relationships that are not directly&lt;br /&gt;related.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;5NF: Isolate Semantically Related Multiple Relationships &lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;There may be practical constrains on information that justify separating&lt;br /&gt;logically related many-to-many relationships.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;ONF: Optimal Normal&lt;br /&gt;Form&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;A model limited to only simple (elemental) facts, as expressed in Object Role&lt;br /&gt;Model notation.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;DKNF: Domain-Key Normal&lt;br /&gt;Form&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;A model free from all modification anomalies.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Remember, these normalization guidelines are cumulative. For a database to&lt;br /&gt;be in 3NF, it must first fulfill all the criteria of a 2NF and 1NF database.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is Stored Procedure?&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;A stored procedure is a named group of SQL statements that have been&lt;br /&gt;previously created and stored in the server database. Stored procedures accept&lt;br /&gt;input parameters so that a single procedure can be used over the network by&lt;br /&gt;several clients using different input data. And when the procedure is modified,&lt;br /&gt;all clients automatically get the new version. Stored procedures reduce network&lt;br /&gt;traffic and improve performance. Stored procedures can be used to help ensure&lt;br /&gt;the integrity of the database.&lt;br /&gt;&lt;br /&gt;e.g. sp_helpdb, sp_renamedb, sp_depends etc.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is Trigger?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;A trigger is a SQL procedure that initiates an action when an event&lt;br /&gt;(INSERT, DELETE or UPDATE) occurs. Triggers are stored in and managed by the&lt;br /&gt;DBMS.Triggers are used to maintain the referential integrity of data by&lt;br /&gt;changing the data in a systematic fashion. A trigger cannot be called or&lt;br /&gt;executed; the DBMS automatically fires the trigger as a result of a data&lt;br /&gt;modification to the associated table. Triggers can be viewed as similar to&lt;br /&gt;stored procedures in that both consist of procedural logic that is stored at&lt;br /&gt;the database level. Stored procedures, however, are not event-drive and are not&lt;br /&gt;attached to a specific table as triggers are. Stored procedures are explicitly&lt;br /&gt;executed by invoking a CALL to the procedure while triggers are implicitly&lt;br /&gt;executed. In addition, triggers can also execute stored procedures.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Nested Trigger: &lt;/em&gt;A trigger can also contain INSERT, UPDATE and DELETE&lt;br /&gt;logic within itself, so when the trigger is fired because of data modification&lt;br /&gt;it can also cause another data modification, thereby firing another trigger. A&lt;br /&gt;trigger that contains data modification logic within itself is called a nested&lt;br /&gt;trigger.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is View?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;main&quot;&gt;A simple view can be thought of as a subset of a table. It can&lt;br /&gt;be used for retrieving data, as well as updating or deleting rows. Rows updated&lt;br /&gt;or deleted in the view are updated or deleted in the table the view was created&lt;br /&gt;with. It should also be noted that as data in the original table changes, so&lt;br /&gt;does data in the view, as views are the way to look at part of the original&lt;br /&gt;table.&lt;/span&gt; The results of using a view are not permanently stored in the&lt;br /&gt;database. The data accessed through a view is actually constructed using&lt;br /&gt;standard T-SQL select command and can come from one to many different base&lt;br /&gt;tables or even other views.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is Index?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;An index is a physical structure containing pointers to the data. Indices&lt;br /&gt;are created in an existing table to locate rows more quickly and efficiently.&lt;br /&gt;It is possible to create an index on one or more columns of a table, and each&lt;br /&gt;index is given a name. The users cannot see the indexes; they are just used to&lt;br /&gt;speed up queries. Effective indexes are one of the best ways to improve&lt;br /&gt;performance in a database application. A table scan happens when there is no&lt;br /&gt;index available to help a query. In a table scan SQL Server examines every row&lt;br /&gt;in the table to satisfy the query results. Table scans are sometimes&lt;br /&gt;unavoidable, but on large tables, scans have a terrific impact on performance.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;Clustered indexes&lt;/em&gt; define the physical sorting of a database table’s rows&lt;br /&gt;in the storage media. For this reason, each database table may have only one&lt;br /&gt;clustered index.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Non-clustered indexes&lt;/em&gt; are created outside of the database table and&lt;br /&gt;contain a sorted list of references to the table itself.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What are the difference between clustered and a non-clustered index?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;A &lt;em&gt;clustered index&lt;/em&gt; is a special type of index that reorders the way&lt;br /&gt;records in the table are physically stored. Therefore table can have only one&lt;br /&gt;clustered index. The leaf nodes of a clustered index contain the data pages.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;A &lt;em&gt;nonclustered index&lt;/em&gt; is a special type of index in which the logical&lt;br /&gt;order of the index does not match the physical stored order of the rows on&lt;br /&gt;disk. The leaf node of a nonclustered index does not consist of the data pages.&lt;br /&gt;Instead, the leaf nodes contain index rows.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What are the different index configurations a table can have?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;A table can have one of the following index configurations:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin-left: 30pt&quot;&gt;&lt;br /&gt;No indexes&lt;br /&gt;&lt;br /&gt;A clustered index&lt;br /&gt;&lt;br /&gt;A clustered index and many nonclustered indexes&lt;br /&gt;&lt;br /&gt;A nonclustered index&lt;br /&gt;&lt;br /&gt;Many nonclustered indexes&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is cursor?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;Cursor is a database object used by applications to manipulate data in a&lt;br /&gt;set on a row-by-row basis, instead of the typical SQL commands that operate on&lt;br /&gt;all the rows in the set at one time.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;In order to work with a cursor we need to perform some steps in the&lt;br /&gt;following order:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;margin-left: 30pt&quot;&gt;&lt;br /&gt;Declare cursor&lt;br /&gt;&lt;br /&gt;Open cursor&lt;br /&gt;&lt;br /&gt;Fetch row from the cursor&lt;br /&gt;&lt;br /&gt;Process fetched row&lt;br /&gt;&lt;br /&gt;Close cursor&lt;br /&gt;&lt;br /&gt;Deallocate cursor&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is the use of DBCC commands?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;DBCC stands for database consistency checker. We use these commands to&lt;br /&gt;check the consistency of the databases, i.e., maintenance, validation task and&lt;br /&gt;status checks.&lt;br /&gt;&lt;br /&gt;E.g. DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly&lt;br /&gt;linked.&lt;br /&gt;&lt;br /&gt;DBCC CHECKALLOC - To check that all pages in a db are correctly allocated.&lt;br /&gt;&lt;br /&gt;DBCC CHECKFILEGROUP - Checks all tables file group for any damage.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is a Linked Server?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;Linked Servers is a concept in SQL Server by which we can add other SQL&lt;br /&gt;Server to a Group and query both the SQL Server dbs using T-SQL Statements.&lt;br /&gt;With a linked server, you can create very clean, easy to follow, SQL statements&lt;br /&gt;that allow remote data to be retrieved, joined and combined with local data.&lt;br /&gt;&lt;br /&gt;Storped Procedure sp_addlinkedserver, sp_addlinkedsrvlogin will be used add new&lt;br /&gt;Linked Server.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is Collation?&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;Collation refers to a set of rules that determine how data is sorted&lt;br /&gt;and compared. Character data is sorted using rules that define the correct&lt;br /&gt;character sequence, with options for specifying case-sensitivity, accent marks,&lt;br /&gt;kana character types and character width.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What are different types of Collation Sensitivity?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;&lt;em&gt;Case sensitivity&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;A and a, B and b, etc.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;Accent sensitivity&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;a and á, o and ó, etc.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;Kana Sensitivity&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;When Japanese kana characters Hiragana and Katakana are treated differently, it&lt;br /&gt;is called Kana sensitive.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;Width sensitivity&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;when a single-byte character (half-width) and the same character when&lt;br /&gt;represented as a double-byte character (full-width) are treated differently&lt;br /&gt;then it is width sensitive.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What’s the difference between a primary key and a unique key?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;Both primary key and unique enforce uniqueness of the column on which they&lt;br /&gt;are defined. But by default primary key creates a clustered index on the&lt;br /&gt;column, where are unique creates a nonclustered index by default. Another major&lt;br /&gt;difference is that, primary key doesn’t allow NULLs, but unique key allows one&lt;br /&gt;NULL only.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;How to implement one-to-one, one-to-many and many-to-many&lt;br /&gt;relationships while designing tables?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;One-to-One relationship can be implemented as a single table and rarely as two&lt;br /&gt;tables with primary and foreign key relationships.&lt;br /&gt;&lt;br /&gt;One-to-Many relationships are implemented by splitting the data into two tables&lt;br /&gt;with primary key and foreign key relationships.&lt;br /&gt;&lt;br /&gt;Many-to-Many relationships are implemented using a junction table with the keys&lt;br /&gt;from both the tables forming the composite primary key of the junction table.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is a NOLOCK?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Using the NOLOCK query optimizer hint is generally considered good practice in&lt;br /&gt;order to improve concurrency on a busy system. When the NOLOCK hint is included&lt;br /&gt;in a SELECT statement, no locks are taken when data is read. The result is a&lt;br /&gt;Dirty Read, which means that another process could be updating the data at the&lt;br /&gt;exact time you are reading it. There are no guarantees that your query will&lt;br /&gt;retrieve the most recent data. The advantage to performance is that your&lt;br /&gt;reading of data will not block updates from taking place, and updates will not&lt;br /&gt;block your reading of data. SELECT statements take Shared (Read) locks. This&lt;br /&gt;means that multiple SELECT statements are allowed simultaneous access, but&lt;br /&gt;other processes are blocked from modifying the data. The updates will queue&lt;br /&gt;until all the reads have completed, and reads requested after the update will&lt;br /&gt;wait for the updates to complete. The result to your system is delay&lt;br /&gt;(blocking).&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is difference between DELETE &amp;amp; TRUNCATE commands?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;Delete command removes the rows from a table based on the condition that we&lt;br /&gt;provide with a WHERE clause. Truncate will actually remove all the rows from a&lt;br /&gt;table and there will be no data in the table after we run the truncate command.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;TRUNCATE&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;TRUNCATE is faster and uses fewer system and transaction log resources than&lt;br /&gt;DELETE.&lt;br /&gt;&lt;br /&gt;TRUNCATE removes the data by deallocating the data pages used to store the&lt;br /&gt;table’s data, and only the page deallocations are recorded in the transaction&lt;br /&gt;log.&lt;br /&gt;&lt;br /&gt;TRUNCATE removes all rows from a table, but the table structure and its&lt;br /&gt;columns, constraints, indexes and so on remain. The counter used by an identity&lt;br /&gt;for new rows is reset to the seed for the column.&lt;br /&gt;&lt;br /&gt;You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY&lt;br /&gt;constraint.&lt;br /&gt;&lt;br /&gt;Because TRUNCATE TABLE is not logged, it cannot activate a trigger.&lt;br /&gt;&lt;br /&gt;TRUNCATE can not be Rolled back.&lt;br /&gt;&lt;br /&gt;TRUNCATE is DDL Command.&lt;br /&gt;&lt;br /&gt;TRUNCATE Resets identity of the table.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;DELETE&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;DELETE removes rows one at a time and records an entry in the transaction log&lt;br /&gt;for each deleted row.&lt;br /&gt;&lt;br /&gt;If you want to retain the identity counter, use DELETE instead. If you want to&lt;br /&gt;remove table definition and its data, use the DROP TABLE statement.&lt;br /&gt;&lt;br /&gt;DELETE Can be used with or without a WHERE clause&lt;br /&gt;&lt;br /&gt;DELETE Activates Triggers.&lt;br /&gt;&lt;br /&gt;DELETE can be rolled back.&lt;br /&gt;&lt;br /&gt;DELETE is DML Command.&lt;br /&gt;&lt;br /&gt;DELETE does not reset identity of the tabl.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Difference between Function and Stored Procedure?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT&lt;br /&gt;section where as Stored procedures cannot be.&lt;br /&gt;&lt;br /&gt;UDFs that return tables can be treated as another rowset. This can be used in&lt;br /&gt;JOINs with other tables.&lt;br /&gt;&lt;br /&gt;Inline UDF’s can be though of as views that take parameters and can be used in&lt;br /&gt;JOINs and other Rowset operations.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;When is the use of UPDATE_STATISTICS command?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;This command is basically used when a large processing of data has&lt;br /&gt;occurred. If a large amount of deletions any modification or Bulk Copy into the&lt;br /&gt;tables has occurred, it has to update the indexes to take these changes into&lt;br /&gt;account. UPDATE_STATISTICS updates the indexes on these tables accordingly.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What types of Joins are possible with Sql Server?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Joins are used in queries to explain how different tables are related. Joins&lt;br /&gt;also let you select data from a table depending upon data from another table.&lt;br /&gt;&lt;br /&gt;Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further&lt;br /&gt;classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is the difference between a HAVING CLAUSE and a WHERE&lt;br /&gt;CLAUSE?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Specifies a search condition for a group or an aggregate. HAVING can be used&lt;br /&gt;only with the SELECT statement. HAVING is typically used in a GROUP BY clause.&lt;br /&gt;When GROUP BY is not used, HAVING behaves like a WHERE clause. Having Clause is&lt;br /&gt;basically used only with the GROUP BY function in a query. WHERE Clause is&lt;br /&gt;applied to each row before they are part of the GROUP BY function in a query.&lt;br /&gt;HAVING criteria is applied after the grouping of rows has occurred.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is sub-query? Explain properties of sub-query.&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;Sub-queries are often referred to as sub-selects, as they allow a SELECT&lt;br /&gt;statement to be executed arbitrarily within the body of another SQL statement.&lt;br /&gt;A sub-query is executed by enclosing it in a set of parentheses. Sub-queries&lt;br /&gt;are generally used to return a single row as an atomic value, though they may&lt;br /&gt;be used to compare values against multiple rows with the IN keyword.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;A subquery is a SELECT statement that is nested within another T-SQL&lt;br /&gt;statement. A subquery SELECT statement if executed independently of the T-SQL&lt;br /&gt;statement, in which it is nested, will return a result set. Meaning a subquery&lt;br /&gt;SELECT statement can standalone and is not depended on the statement in which&lt;br /&gt;it is nested. A subquery SELECT statement can return any number of values, and&lt;br /&gt;can be found in, the column list of a SELECT statement, a FROM, GROUP BY,&lt;br /&gt;HAVING, and/or ORDER BY clauses of a T-SQL statement. A Subquery can also be&lt;br /&gt;used as a parameter to a function call. Basically a subquery can be used&lt;br /&gt;anywhere an expression can be used.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Properties of Sub-Query&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;A subquery must be enclosed in the parenthesis.&lt;br /&gt;&lt;br /&gt;A subquery must be put in the right hand of the comparison operator, and&lt;br /&gt;&lt;br /&gt;A subquery cannot contain a ORDER-BY clause.&lt;br /&gt;&lt;br /&gt;A query can contain more than one sub-query.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What are types of sub-queries?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;Single-row subquery, where the subquery returns only one row.&lt;br /&gt;&lt;br /&gt;Multiple-row subquery, where the subquery returns multiple rows,.and&lt;br /&gt;&lt;br /&gt;Multiple column subquery, where the subquery returns multiple columns.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is SQL Profiler?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;SQL Profiler is a graphical tool that allows system administrators to&lt;br /&gt;monitor events in an instance of Microsoft SQL Server. You can capture and save&lt;br /&gt;data about each event to a file or SQL Server table to analyze later. For&lt;br /&gt;example, you can monitor a production environment to see which stored&lt;br /&gt;procedures are hampering performances by executing too slowly.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Use SQL Profiler to monitor only the events in which you are interested. If&lt;br /&gt;traces are becoming too large, you can filter them based on the information you&lt;br /&gt;want, so that only a subset of the event data is collected. Monitoring too many&lt;br /&gt;events adds overhead to the server and the monitoring process and can cause the&lt;br /&gt;trace file or trace table to grow very large, especially when the monitoring&lt;br /&gt;process takes place over a long period of time.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is User Defined Functions?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;User-Defined Functions allow defining its own T-SQL functions that can accept 0&lt;br /&gt;or more parameters and return a single scalar data value or a table data type.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What kind of User-Defined Functions can be created?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;There are three types of User-Defined functions in SQL Server 2000 and they&lt;br /&gt;are Scalar, Inline Table-Valued and Multi-statement Table-valued.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Scalar User-Defined Function&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;A Scalar user-defined function returns one of the scalar data types. Text,&lt;br /&gt;ntext, image and timestamp data types are not supported. These are the type of&lt;br /&gt;user-defined functions that most developers are used to in other programming&lt;br /&gt;languages. You pass in 0 to many parameters and you get a return value.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Inline Table-Value User-Defined Function&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;An Inline Table-Value user-defined function returns a table data type and is an&lt;br /&gt;exceptional alternative to a view as the user-defined function can pass&lt;br /&gt;parameters into a T-SQL select command and in essence provide us with a&lt;br /&gt;parameterized, non-updateable view of the underlying tables.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Multi-statement Table-Value User-Defined Function&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;A Multi-Statement Table-Value user-defined function returns a table and is also&lt;br /&gt;an exceptional alternative to a view as the function can support multiple T-SQL&lt;br /&gt;statements to build the final result where the view is limited to a single&lt;br /&gt;SELECT statement. Also, the ability to pass parameters into a T-SQL select&lt;br /&gt;command or a group of them gives us the capability to in essence create a&lt;br /&gt;parameterized, non-updateable view of the data in the underlying tables. Within&lt;br /&gt;the create function command you must define the table structure that is being&lt;br /&gt;returned. After creating this type of user-defined function, It can be used in&lt;br /&gt;the FROM clause of a T-SQL command unlike the behavior found when using a&lt;br /&gt;stored procedure which can also return record sets.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Which TCP/IP port does SQL Server run on? How can it be changed?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;SQL Server runs on port 1433. It can be changed from the Network Utility&lt;br /&gt;TCP/IP properties –&amp;gt; Port number. both on client and the server.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What are the authentication modes in SQL Server? How can it be&lt;br /&gt;changed?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;Windows mode and mixed mode (SQL &amp;amp; Windows).&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;To change authentication mode in SQL Server&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt; click Start, Programs, and Microsoft SQL Server and click&lt;br /&gt;SQL Enterprise Manager to run SQL Enterprise Manager from the Microsoft SQL&lt;br /&gt;Server program group. Select the server then from the Tools menu select SQL&lt;br /&gt;Server Configuration Properties, and choose the Security page.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Where SQL server user’s names and passwords are are stored in sql&lt;br /&gt;server?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;They get stored in master db in the sysxlogins table.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Which command using Query Analyzer will give you the version of SQL&lt;br /&gt;server and operating system? &lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;/u&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SELECT&lt;span&gt;  &lt;/span&gt;SERVERPROPERTY(&#039;productversion&#039;), SERVERPROPERTY (&#039;productlevel&#039;), SERVERPROPERTY (&#039;edition&#039;)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is SQL server agent?&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;SQL Server agent plays an important role in the day-to-day tasks of a&lt;br /&gt;database administrator (DBA). It is often overlooked as one of the main tools&lt;br /&gt;for SQL Server management. Its purpose is to ease the implementation of tasks&lt;br /&gt;for the DBA, with its full-function scheduling engine, which allows you to&lt;br /&gt;schedule your own jobs and scripts.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Can a stored procedure call itself or recursive stored procedure? How many&lt;br /&gt;levels SP nesting possible?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;Yes. Because Transact-SQL supports recursion, you can write stored&lt;br /&gt;procedures that call themselves. Recursion can be defined as a method of&lt;br /&gt;problem solving wherein the solution is arrived at by repetitively applying it&lt;br /&gt;to subsets of the problem. A common application of recursive logic is to&lt;br /&gt;perform numeric computations that lend themselves to repetitive evaluation by&lt;br /&gt;the same processing steps. Stored procedures are nested when one stored&lt;br /&gt;procedure calls another or executes managed code by referencing a CLR routine,&lt;br /&gt;type, or aggregate. You can nest stored procedures and managed code references&lt;br /&gt;up to 32 levels.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is @@ERROR?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;The @@ERROR automatic variable returns the error code of the last&lt;br /&gt;Transact-SQL statement. If there was no error, @@ERROR returns zero. Because&lt;br /&gt;@@ERROR is reset after each Transact-SQL statement, it must be saved to a&lt;br /&gt;variable if it is needed to process it further after checking it.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is Raise error? &lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;Stored procedures report errors to client applications via the RAISERROR&lt;br /&gt;command. RAISERROR doesn’t change the flow of a procedure; it merely displays&lt;br /&gt;an error message, sets the @@ERROR automatic variable, and optionally writes&lt;br /&gt;the message to the SQL Server error log and the NT application event log.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is log shipping?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;Log shipping is the&lt;br /&gt;process of automating the backup of database and transaction log files on a&lt;br /&gt;production SQL server, and then restoring them onto a standby server.&lt;br /&gt;Enterprise Editions only supports log shipping. In log shipping the&lt;br /&gt;transactional log file from one server is automatically updated into the backup&lt;br /&gt;database on the other server. If one server fails, the other server will have&lt;br /&gt;the same db can be used this as the Disaster Recovery plan. The key feature of&lt;br /&gt;log shipping is that is will automatically backup transaction logs throughout&lt;br /&gt;the day and automatically restore them on the standby server at defined&lt;br /&gt;interval.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is the difference between a local and a global variable?&lt;/u&gt;&lt;/strong&gt;&lt;u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/u&gt;A &lt;em&gt;local temporary &lt;/em&gt;table exists only for the duration of a connection&lt;br /&gt;or, if defined inside a compound statement, for the duration of the compound&lt;br /&gt;statement.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;A &lt;em&gt;global temporary&lt;/em&gt; table remains in the database permanently, but the&lt;br /&gt;rows exist only within a given connection. When connection is closed, the data&lt;br /&gt;in the global temporary table disappears. However, the table definition remains&lt;br /&gt;with the database for access when database is opened next time.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What are the different types of replication? Explain.&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;The SQL Server&lt;br /&gt;2000-supported replication types are as follows:&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;Transactional&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;Snapshot&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;Merge&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Snapshot replication&lt;/em&gt;&lt;/strong&gt; distributes data exactly as it&lt;br /&gt;appears at a specific moment in time and does not monitor for updates to the&lt;br /&gt;data. Snapshot replication is best used as a method for replicating data that&lt;br /&gt;changes infrequently or where the most up-to-date values (low latency) are not&lt;br /&gt;a requirement. When synchronization occurs, the entire snapshot is generated&lt;br /&gt;and sent to Subscribers.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Transactional replication&lt;/em&gt;&lt;/strong&gt;, an initial snapshot of&lt;br /&gt;data is applied at Subscribers, and then when data modifications are made at&lt;br /&gt;the Publisher, the individual transactions are captured and propagated to&lt;br /&gt;Subscribers.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Merge replication&lt;/em&gt;&lt;/strong&gt; is the process of distributing&lt;br /&gt;data from Publisher to Subscribers, allowing the Publisher and Subscribers to&lt;br /&gt;make updates while connected or disconnected, and then merging the updates&lt;br /&gt;between sites when they are connected.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What are the OS services that the SQL Server installation adds?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;MS SQL SERVER SERVICE, SQL AGENT SERVICE, DTC (Distribution transac&lt;br /&gt;co-ordinator)&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What are three SQL keywords used to change or set someone’s&lt;br /&gt;permissions?&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;GRANT, DENY, and REVOKE.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What does it mean to have quoted_identifier on? What are the&lt;br /&gt;implications of having it off?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;When SET QUOTED_IDENTIFIER&lt;br /&gt;is ON, identifiers can be delimited by double quotation marks, and literals&lt;br /&gt;must be delimited by single quotation marks. When SET QUOTED_IDENTIFIER is OFF,&lt;br /&gt;identifiers cannot be quoted and must follow all Transact-SQL rules for&lt;br /&gt;identifiers.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is the STUFF function and how does it differ from the REPLACE&lt;br /&gt;function?&lt;/u&gt; &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;STUFF function to overwrite existing characters. Using this syntax, STUFF(string_expression,&lt;br /&gt;start, length, replacement_characters), string_expression is the string that&lt;br /&gt;will have characters substituted, start is the starting position, length is the&lt;br /&gt;number of characters in the string that are substituted, and&lt;br /&gt;replacement_characters are the new characters interjected into the string.&lt;br /&gt;&lt;br /&gt;REPLACE function to replace existing characters of all occurance. Using this&lt;br /&gt;syntax REPLACE(string_expression, search_string, replacement_string), where&lt;br /&gt;every incidence of search_string found in the string_expression will be&lt;br /&gt;replaced with replacement_string.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Using query analyzer, name 3 ways to get an accurate count of the&lt;br /&gt;number of records in a table?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;SELECT * FROM table1&lt;br /&gt;&lt;br /&gt;SELECT COUNT(*) FROM table1&lt;br /&gt;&lt;br /&gt;SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND indid &amp;lt; 2&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;How to rebuild Master Database?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Shutdown Microsoft SQL Server 2000, and then run Rebuildm.exe. This is located&lt;br /&gt;in the Program FilesMicrosoft SQL Server80ToolsBinn directory.&lt;br /&gt;&lt;br /&gt;In the Rebuild Master dialog box, click Browse.&lt;br /&gt;&lt;br /&gt;In the Browse for Folder dialog box, select the Data folder on the SQL Server&lt;br /&gt;2000 compact disc or in the shared network directory from which SQL Server 2000&lt;br /&gt;was installed, and then click OK.&lt;br /&gt;&lt;br /&gt;Click Settings. In the Collation Settings dialog box, verify or change settings&lt;br /&gt;used for the master database and all other databases.&lt;br /&gt;&lt;br /&gt;Initially, the default collation settings are shown, but these may not match&lt;br /&gt;the collation selected during setup. You can select the same settings used&lt;br /&gt;during setup or select new collation settings. When done, click OK.&lt;br /&gt;&lt;br /&gt;In the Rebuild Master dialog box, click Rebuild to start the process.&lt;br /&gt;&lt;br /&gt;The Rebuild Master utility reinstalls the master database.&lt;br /&gt;&lt;br /&gt;To continue, you may need to stop a server that is running.&lt;br /&gt;&lt;br /&gt;Source: http://msdn2.microsoft.com/en-us/library/aa197950(SQL.80).aspx&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is the basic functions for master, msdb, model, tempdb databases?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;&lt;em&gt;Master&lt;/em&gt;&lt;/strong&gt; database holds information for all databases located&lt;br /&gt;on the SQL Server instance and is the glue that holds the engine together.&lt;br /&gt;Because SQL Server cannot start without a functioning master database, you must&lt;br /&gt;administer this database with care.&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;&lt;em&gt;msdb &lt;/em&gt;&lt;/strong&gt;database stores information regarding database backups,&lt;br /&gt;SQL Agent information, DTS packages, SQL Server jobs, and some replication&lt;br /&gt;information such as for log shipping.&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;&lt;em&gt;tempdb&lt;/em&gt;&lt;/strong&gt; holds temporary objects such as global and local&lt;br /&gt;temporary tables and stored procedures.&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;&lt;em&gt;model&lt;/em&gt;&lt;/strong&gt; is essentially a template database used in the creation&lt;br /&gt;of any new user database created in the instance.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What are primary keys and foreign keys?&lt;/u&gt; &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;txt&quot;&gt;&lt;strong&gt;&lt;em&gt;Primary keys&lt;/em&gt;&lt;/strong&gt; are the unique identifiers for each&lt;br /&gt;row. They must contain unique values and cannot be null. Due to their&lt;br /&gt;importance in relational databases, Primary keys are the most fundamental of&lt;br /&gt;all keys and constraints. A table can have only one Primary key.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;txt&quot;&gt;&lt;strong&gt;&lt;em&gt;Foreign keys&lt;/em&gt;&lt;/strong&gt; are both a method of ensuring data&lt;br /&gt;integrity and a manifestation of the relationship between tables.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;What is data integrity? Explain constraints?&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;dropcap&quot;&gt;D&lt;/span&gt;ata integrity is an important feature in SQL&lt;br /&gt;Server. When used properly, it ensures that data is accurate, correct, and&lt;br /&gt;valid. It also acts as a trap for otherwise undetectable bugs within&lt;br /&gt;applications.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;A &lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;/strong&gt; constraint is a unique&lt;br /&gt;identifier for a row within a database table. Every table should have a primary&lt;br /&gt;key constraint to uniquely identify each row and only one primary key&lt;br /&gt;constraint can be created for each table. The primary key constraints are used&lt;br /&gt;to enforce entity integrity. &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;A &lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;UNIQUE&lt;/span&gt;&lt;/strong&gt; constraint enforces the&lt;br /&gt;uniqueness of the values in a set of columns, so no duplicate values are&lt;br /&gt;entered. The unique key constraints are used to enforce entity integrity as the&lt;br /&gt;primary key constraints. &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;A &lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;FOREIGN KEY&lt;/span&gt;&lt;/strong&gt; constraint prevents any&lt;br /&gt;actions that would destroy links between tables with the corresponding data&lt;br /&gt;values. A foreign key in one table points to a primary key in another table.&lt;br /&gt;Foreign keys prevent actions that would leave rows with foreign key values when&lt;br /&gt;there are no primary keys with that value. The foreign key constraints are used&lt;br /&gt;to enforce referential integrity. &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;A &lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;CHECK&lt;/span&gt;&lt;/strong&gt; constraint is used to limit&lt;br /&gt;the values that can be placed in a column. The check constraints are used to&lt;br /&gt;enforce domain integrity. &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 10pt; font-family: Verdana&quot;&gt;A &lt;strong&gt;&lt;span style=&quot;font-family: Verdana&quot;&gt;NOT NULL&lt;/span&gt;&lt;/strong&gt; constraint enforces that&lt;br /&gt;the column will not accept null values. The not null constraints are used to&lt;br /&gt;enforce domain integrity, as the check constraints.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;What are the properties of the Relational tables?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Relational tables have six properties:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Values are atomic.&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Column values are of the same&lt;br /&gt;	kind.&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Each row is unique.&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;The sequence of columns is&lt;br /&gt;	insignificant.&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;The sequence of rows is&lt;br /&gt;	insignificant.&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Each column must have a&lt;br /&gt;	unique name.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;What is De-normalization?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;De-normalization is the process of attempting to optimize the performance of a&lt;br /&gt;database by adding redundant data. It is sometimes necessary because current DBMSs&lt;br /&gt;implement the relational model poorly. A true relational DBMS would allow for a&lt;br /&gt;fully normalized database at the logical level, while providing physical&lt;br /&gt;storage of data that is tuned for high performance. De-normalization is a&lt;br /&gt;technique to move from higher to lower normal forms of database modeling in&lt;br /&gt;order to speed up database access.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;How to get @@error and @@rowcount at the same time?&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;If @@Rowcount is checked after Error checking statement then it will have 0&lt;br /&gt;as the value of @@Recordcount as it would have been reset.&lt;br /&gt;&lt;br /&gt;And if @@Recordcount is checked before the error-checking statement then&lt;br /&gt;@@Error would get reset. To get @@error and @@rowcount at the same time do both&lt;br /&gt;in same statement and store them in local variable. SELECT @RC = @@ROWCOUNT,&lt;br /&gt;@ER = @@ERROR&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;What is Identity?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Identity (or AutoNumber) is a column that automatically generates numeric&lt;br /&gt;values. A start and increment value can be set, but most DBA leave these at 1.&lt;br /&gt;A GUID column also generates numbers, the value of this cannot be controled. Identity/GUID&lt;br /&gt;columns do not need to be indexed.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;What is a Scheduled Jobs or What is a Scheduled Tasks? &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name=&quot;sectionToggle0&quot;&gt;&lt;/a&gt;Scheduled tasks let user automate processes that run on&lt;br /&gt;regular or predictable cycles. User can schedule administrative tasks, such as&lt;br /&gt;cube processing, to run during times of slow business activity. User can also&lt;br /&gt;determine the order in which tasks run by creating job steps within a SQL&lt;br /&gt;Server Agent job. E.g. Back up database, Update Stats of Tables. Job steps give&lt;br /&gt;user control over flow of execution. If one job fails, user can configure&lt;br /&gt;SQL Server Agent to continue to run the remaining tasks or to stop execution.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;What is a table called, if it does not have neither Cluster nor&lt;br /&gt;Non-cluster Index? What is it used for?&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;Unindexed table or &lt;strong&gt;&lt;em&gt;Heap&lt;/em&gt;&lt;/strong&gt;. Microsoft Press Books and Book On&lt;br /&gt;Line (BOL) refers it as Heap.&lt;br /&gt;&lt;br /&gt;A heap is a table that does not have a clustered index and, therefore, the&lt;br /&gt;pages are not linked by pointers. The IAM pages are the only structures that&lt;br /&gt;link the pages in a table together.&lt;br /&gt;&lt;br /&gt;Unindexed tables are good for fast storing of data. Many times it is better to&lt;br /&gt;drop all indexes from table and than do bulk of inserts and to restore those&lt;br /&gt;indexes after that.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;What is BCP? When does it used? &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;BulkCopy is a tool used to copy huge amount of data from tables and views. BCP&lt;br /&gt;does not copy the structures same as source to destination.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;How do you load large data to the SQL server database?&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;BulkCopy is a tool used to copy huge amount of data from tables. BULK&lt;br /&gt;INSERT command helps to Imports a data file into a database table or view in a&lt;br /&gt;user-specified format.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Can we rewrite subqueries into simple select statements or with joins? &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Subqueries can often be re-written to use a standard outer join, resulting in&lt;br /&gt;faster performance. As we may know, an outer join uses the plus sign (+)&lt;br /&gt;operator to tell the database to return all non-matching rows with NULL values.&lt;br /&gt;Hence we combine the outer join with a NULL test in the WHERE clause to&lt;br /&gt;reproduce the result set without using a sub-query.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Can SQL Servers linked to other servers like Oracle?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;SQL Server can be lined to any server provided it has OLE-DB provider from&lt;br /&gt;Microsoft to allow a link. E.g. Oracle has a OLE-DB provider for oracle that&lt;br /&gt;Microsoft provides to add it as linked server to SQL Server group.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;How to know which index a table is using? &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;SELECT table_name,index_name FROM user_constraints&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;How to copy the tables, schema and views from one SQL server to another?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Microsoft SQL Server 2000 Data Transformation Services (DTS) is a set of&lt;br /&gt;graphical tools and programmable objects that lets user extract, transform, and&lt;br /&gt;consolidate data from disparate sources into single or multiple destinations.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;What is Self Join?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;This is a particular case when one table joins to itself, with one or two&lt;br /&gt;aliases to avoid confusion. A self join can be of any type, as long as the&lt;br /&gt;joined tables are the same. A self join is rather unique in that it involves a&lt;br /&gt;relationship with only one table. The common example is when company have a&lt;br /&gt;hierarchal reporting structure whereby one member of staff reports to another.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;What is Cross Join?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;A cross join that does not have a WHERE clause produces the Cartesian product&lt;br /&gt;of the tables involved in the join. The size of a Cartesian product result set&lt;br /&gt;is the number of rows in the first table multiplied by the number of rows in&lt;br /&gt;the second table. The common example is when company wants to combine each&lt;br /&gt;product with a pricing table to analyze each product at each price.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Which virtual table does a trigger use?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Inserted and Deleted.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;List few advantages of Stored Procedure.&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Stored procedure can reduced&lt;br /&gt;	network traffic and latency, boosting application performance.&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Stored procedure execution&lt;br /&gt;	plans can be reused, staying cached in SQL Server’s memory, reducing&lt;br /&gt;	server overhead.&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Stored procedures help&lt;br /&gt;	promote code reuse.&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Stored procedures can&lt;br /&gt;	encapsulate logic. You can change stored procedure code without affecting&lt;br /&gt;	clients.&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;Stored procedures provide&lt;br /&gt;	better security to your data.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;What is DataWarehousing?&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;Subject-oriented&lt;/strong&gt;,&lt;br /&gt;	meaning that the data in the database is organized so that all the data&lt;br /&gt;	elements relating to the same real-world event or object are linked&lt;br /&gt;	together;&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;Time-variant&lt;/strong&gt;,&lt;br /&gt;	meaning that the changes to the data in the database are tracked and&lt;br /&gt;	recorded so that reports can be produced showing changes over time;&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;Non-volatile&lt;/strong&gt;,&lt;br /&gt;	meaning that data in the database is never over-written or deleted, once&lt;br /&gt;	committed, the data is static, read-only, but retained for future&lt;br /&gt;	reporting;&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;Integrated&lt;/strong&gt;,&lt;br /&gt;	meaning that the database contains data from most or all of an&lt;br /&gt;	organization’s operational applications, and that this data is made&lt;br /&gt;	consistent.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;What is OLTP(OnLine Transaction Processing)?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In OLTP - online transaction processing systems relational database design use&lt;br /&gt;the discipline of data modeling and generally follow the Codd rules of data&lt;br /&gt;normalization in order to ensure absolute data integrity. Using these rules&lt;br /&gt;complex information is broken down into its most simple structures (a table)&lt;br /&gt;where all of the individual atomic level elements relate to each other and&lt;br /&gt;satisfy the normalization rules.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;How do SQL server 2000 and XML linked? Can XML be used to access data?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;FOR XML (ROW, AUTO, EXPLICIT)&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;You can execute SQL queries against existing relational databases to return&lt;br /&gt;results as XML rather than standard rowsets. These queries can be executed&lt;br /&gt;directly or from within stored procedures. To retrieve XML results, use the FOR&lt;br /&gt;XML clause of the SELECT statement and specify an XML mode of RAW, AUTO, or&lt;br /&gt;EXPLICIT.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;OPENXML&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;OPENXML is a Transact-SQL keyword that provides a relational/rowset view over&lt;br /&gt;an in-memory XML document. OPENXML is a rowset provider similar to a table or a&lt;br /&gt;view. OPENXML provides a way to access XML data within the Transact-SQL context&lt;br /&gt;by transferring data from an XML document into the relational tables. Thus,&lt;br /&gt;OPENXML allows you to manage an XML document and its interaction with the&lt;br /&gt;relational environment.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;What is an execution plan? When would you use it? How would you view the&lt;br /&gt;execution plan?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;An execution plan is basically a road map that graphically or textually shows&lt;br /&gt;the data retrieval methods chosen by the SQL Server query optimizer for a&lt;br /&gt;stored procedure or ad-hoc query and is a very useful tool for a developer to&lt;br /&gt;understand the performance characteristics of a query or stored procedure since&lt;br /&gt;the plan is the one that SQL Server will place in its cache and use to execute&lt;br /&gt;the stored procedure or query. From within Query Analyzer is an option called&lt;br /&gt;“Show Execution Plan” (located on the Query drop-down menu). If this option is&lt;br /&gt;turned on it will display query execution plan in separate window when query is&lt;br /&gt;ran again.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/SQL-Interview-questions-b1-p21.htm</guid>
	</item>
	<item>
		<title>Ways to improve SQL performance</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-05T11:57:01Z</pubDate>
		<description>&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;1. Normalizing:&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;Normalize your table’s schema in such a way that all tables&lt;br /&gt;are reduced in &lt;span&gt;        &lt;/span&gt;columns and are&lt;br /&gt;related to other table with some reference.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;That will improve performance while you are fetching data&lt;br /&gt;from tables &lt;span&gt;  &lt;/span&gt;that will also reduce the&lt;br /&gt;fetching of redundant data.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;2. Define Primary and&lt;br /&gt;Foreign keys:&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;Make relation of your table in such a way that you can&lt;br /&gt;access any &lt;span&gt;        &lt;/span&gt;combination of data&lt;br /&gt;from various tables just by referencing keys.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;3. Choose the most&lt;br /&gt;appropriate data types.&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;This is the main issue when actual data will be stored on&lt;br /&gt;local disk, &lt;span&gt;       &lt;/span&gt;because if you have&lt;br /&gt;given some inappropriate data type then it will &lt;span&gt; &lt;/span&gt;consume more space than actually needed. That will degrade the disk&lt;br /&gt;IO &lt;span&gt;          &lt;/span&gt;performance.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;4. Make Index:&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;Try to make Index on such columns which are frequently used&lt;br /&gt;in &lt;span&gt;           &lt;/span&gt;searching operations, so it&lt;br /&gt;will improve our query performance.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;Do not make more indexes on one table that it will degrade&lt;br /&gt;the &lt;span&gt; &lt;/span&gt;performance, because when table is to&lt;br /&gt;be updated by updating or inserting new &lt;span&gt;          &lt;/span&gt;data,&lt;br /&gt;indexes &lt;span&gt;   &lt;/span&gt;also will be updated, so try to&lt;br /&gt;make fewer indexes on table.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;5. Return Values:&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;Return only those columns and rows which are actually needed&lt;br /&gt;for &lt;span&gt;        &lt;/span&gt;requirement. &lt;span&gt;    &lt;/span&gt;Do not try to fetch all rows and columns&lt;br /&gt;which are not needed, &lt;span&gt; &lt;/span&gt;because it will&lt;br /&gt;slow down the fetching as well as make the high IO operations.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;6. Avoid Expensive&lt;br /&gt;operations:&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;Try to avoid expensive operations such as “LIKE”, because we&lt;br /&gt;are &lt;span&gt;      &lt;/span&gt;normally using “LIKE %abc%”&lt;br /&gt;wildcard entries…and it will require table scan &lt;span&gt;    &lt;/span&gt;and it will make very slow response of query result.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;7. Avoid Explicit or&lt;br /&gt;Implicit functions in WHERE Clause:&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;The optimizer cannot always select an index by using columns&lt;br /&gt;in a &lt;span&gt;         &lt;/span&gt;WHERE clause that are inside&lt;br /&gt;functions. Columns in a WHERE clause are seen &lt;span&gt;       &lt;/span&gt;as&lt;br /&gt;an expression rather than a column. Therefore, the columns are not used in the&lt;br /&gt;execution plan optimization.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#039;Lucida Console&#039;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#039;Lucida Console&#039;&quot;&gt;EX: do not use where clause like this,&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#039;Lucida Console&#039;&quot;&gt;SELECT&lt;br /&gt;OrderID FROM NorthWind.dbo.Orders WHERE DATEADD(day, 15, OrderDate) =&lt;br /&gt;&#039;07/23/1996&#039;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;span&gt;            &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;Instead, we can use like,&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#039;Lucida Console&#039;&quot;&gt;SELECT&lt;br /&gt;OrderID FROM NorthWind.dbo.Orders WHERE OrderDate = DATEADD(day, -15,&lt;br /&gt;&#039;07/23/1996&#039;)&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%&quot;&gt;8. Use stored Procedures and Parameterized Queries:&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; font-weight: normal&quot;&gt;Advantages of&lt;br /&gt;using stored procedures are,&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%&quot;&gt;Logical separation of business logic&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; font-weight: normal&quot;&gt;: we can reduce the amount of code which is written in application code,&lt;br /&gt;so we can separate out some logic from application and embed into stored&lt;br /&gt;procedure. This has its own advantage like we have to change only single change&lt;br /&gt;in stored procedure and it will be reflected into all places.&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%&quot;&gt;Reduced deployment time:&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; font-weight: normal&quot;&gt; When we have&lt;br /&gt;embedded sql command in application code then if we want to change that&lt;br /&gt;business logic then after changes we have to deploy whole application again,&lt;br /&gt;but is we have used stored procedures then it requires only change in stored&lt;br /&gt;procedures. &lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%&quot;&gt;Reduced Network bandwidth:&lt;span&gt; &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; font-weight: normal&quot;&gt;if we supply whole sql command to the server then it&lt;br /&gt;will require more bandwidth, but if we have used stored procedures then we just&lt;br /&gt;have to supply only stored procedure name and its parameters.&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%&quot;&gt;SQL injections: &lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; font-weight: normal&quot;&gt;stored procedure will protect against sql injections which are produced&lt;br /&gt;by direct user input which is used in sql command.&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; font-weight: normal&quot;&gt; &lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%&quot;&gt;9. Minimize cursor use:&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; font-weight: normal&quot;&gt;Cursors force&lt;br /&gt;database engine to repeatedly fetch rows, negotiate blocking, manage locks, and&lt;br /&gt;transmit results. Use forward only and read only cursors unless you wan tot&lt;br /&gt;update the tables. In cursors more locks are needed.&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; font-weight: normal&quot;&gt;Forward only and&lt;br /&gt;read only cursors are fastest and least resource intensive to get data from the&lt;br /&gt;server.&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; font-weight: normal&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%&quot;&gt; Use Temporary Tables and Table Variables&lt;br /&gt;Appropriately&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; font-weight: normal&quot;&gt; &lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;p style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;br /&gt;If your application frequently&lt;br /&gt;creates temporary tables, consider using the &lt;strong&gt;table&lt;/strong&gt; variable or a&lt;br /&gt;permanent table. You can use the &lt;strong&gt;table&lt;/strong&gt; data type to store a row set in&lt;br /&gt;memory. &lt;strong&gt;Table&lt;/strong&gt; variables are cleaned up automatically at the end of the&lt;br /&gt;function, stored procedure, or batch that they are defined in. Many requests to&lt;br /&gt;create temporary tables may cause contention in both the tempdb database and in&lt;br /&gt;the system tables. Very large temporary tables are also problematic. If you&lt;br /&gt;find that you are creating many large temporary tables, you may want to&lt;br /&gt;consider a permanent table that can be truncated between uses.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;br /&gt;Table variables use the tempdb&lt;br /&gt;database in a manner that is similar to how table variables use temporary&lt;br /&gt;tables, so avoid large table variables. Also, table variables are not&lt;br /&gt;considered by the optimizer when the optimizer generates execution plans and&lt;br /&gt;parallel queries. Therefore, table variables may cause decreased performance.&lt;br /&gt;Finally, table variables cannot be indexed as flexibly as temporary tables.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;br /&gt;You have to test temporary table&lt;br /&gt;and table variable usage for performance. Test with many users for scalability&lt;br /&gt;to determine the approach that is best for each situation. Also, be aware that&lt;br /&gt;there may be concurrency issues when there are many temporary tables and variables&lt;br /&gt;that are requesting resources in the tempdb database.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%&quot;&gt;11. Avoid LEFT JOINs and NULLs:&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; color: black; font-weight: normal&quot;&gt;LEFT&lt;br /&gt;JOIN can be used to retrieve all of the rows from a first table and all&lt;br /&gt;matching rows from a second table, plus all rows from the second table that do&lt;br /&gt;not match the first one. For example, if you wanted to return every Customer&lt;br /&gt;and their orders, a LEFT JOIN would show the Customers who did and did not have&lt;br /&gt;orders.&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; color: black; font-weight: normal&quot;&gt;LEFT&lt;br /&gt;JOINs are costly since they involve matching data against NULL (nonexistent)&lt;br /&gt;data. In some cases this is unavoidable, but the cost can be high. A LEFT JOIN&lt;br /&gt;is more costly than an INNER JOIN, so if you could rewrite a query so it&lt;br /&gt;doesn&#039;t use a LEFT JOIN, it could pay huge dividends.&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; color: black; font-weight: normal&quot;&gt;One&lt;br /&gt;technique to speed up a query that uses a LEFT JOIN involves creating a TABLE&lt;br /&gt;datatype and inserting all of the rows from the first table (the one on the&lt;br /&gt;left-hand side of the LEFT JOIN), then updating the TABLE datatype with the&lt;br /&gt;values from the second table. This technique is a two-step process, but could&lt;br /&gt;save a lot of time compared to a standard LEFT JOIN. A good rule is to try out&lt;br /&gt;different techniques and time each of them until you get the best performing&lt;br /&gt;query for your application.&lt;span&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;h3 style=&quot;line-height: 140%; vertical-align: top&quot;&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%; color: black&quot;&gt;12. &lt;/span&gt;&lt;span style=&quot;font-size: 10pt; line-height: 140%; font-family: Helvetica; color: #010100&quot;&gt;Rewriting query with OR conditions&lt;br /&gt;as a UNION&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 140%&quot;&gt;&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;p style=&quot;margin-bottom: 12pt&quot; class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #010100&quot;&gt;You&lt;br /&gt;can speedup your query,&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: black&quot;&gt;SELECT * FROM table WHERE (Field1 = &#039;Value1&#039;) OR (Field2 = &#039;Value2&#039;)&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: black&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: black&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #010100&quot;&gt;By creating indexes on each field in the&lt;br /&gt;above conditions and by using a UNION operator instead &lt;br /&gt;&lt;br /&gt;of using OR: &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #010100&quot;&gt;&lt;span&gt;            &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: black&quot;&gt;SELECT&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: black&quot;&gt; ... &lt;strong&gt;WHERE&lt;/strong&gt; &lt;strong&gt;Field1 = &#039;Value1&#039;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: black&quot;&gt;UNION&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: black&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: black&quot;&gt;SELECT&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: black&quot;&gt; ... &lt;strong&gt;WHERE&lt;/strong&gt; &lt;strong&gt;Field2 = &#039;Value2&#039;&lt;/strong&gt;&lt;/span&gt;&lt;span style=&quot;color: #010100&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: black&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;&lt;span style=&quot;font-size: 12pt; font-family: &#039;Times New Roman&#039;; font-style: normal&quot;&gt;13. SP Performance Improvement without&lt;br /&gt;changing T-SQL&lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;span&gt; &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;There&lt;br /&gt;are two ways, which can be used to improve the performance of Stored Procedure&lt;br /&gt;(SP) without making T-SQL changes in SP.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;Do not prefix your Stored&lt;br /&gt;	Procedure with sp_. &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;	In SQL Server, all system SPs are prefixed with sp_. When any SP is called&lt;br /&gt;	which begins sp_ it is looked into masters database first before it is&lt;br /&gt;	looked into the database it is called in.&lt;/li&gt;&lt;br /&gt;	&lt;li class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;Call your Stored Procedure&lt;br /&gt;	prefixed with dbo.SPName - fully qualified name. &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;	When SP is called prefixed with dbo. Or database.dbo. It will prevent SQL&lt;br /&gt;	Server from placing a COMPILE lock on the procedure. While SP executes it&lt;br /&gt;	determines if all objects referenced in the code have the same owners as&lt;br /&gt;	the objects in the current cached procedure plan.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 14pt&quot;&gt;Some more, little but very important tips….. &lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 14pt&quot;&gt; &lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;1.&lt;br /&gt;Know your data and business application well.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Familiarize yourself with these sources; you must be aware of the data volume&lt;br /&gt;and distribution in your database.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;2.&lt;br /&gt;Test your queries with realistic data.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;A SQL statement tested with unrealistic data may behave differently when used&lt;br /&gt;in production. To ensure rigorous testing, the data distribution in the test&lt;br /&gt;environment must also closely resemble that in the production environment.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;3.&lt;br /&gt;Write identical SQL statements in your applications.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Take full advantage of stored procedures, and functions wherever possible. The&lt;br /&gt;benefits are performance gain as they are precompiled.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;4.&lt;br /&gt;Use indexes on the tables carefully.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Be sure to create all the necessary indexes on the tables. However, too many of&lt;br /&gt;them can degrade performance.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;5.&lt;br /&gt;Make an indexed path available.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;To take advantage of indexes, write your SQL in such a manner that an indexed&lt;br /&gt;path is available to it. Using SQL hints is one of the ways to ensure the index&lt;br /&gt;is used.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;6.&lt;br /&gt;Understand the Optimizer.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Understand the optimizer how it uses indexes, where clause, order by clause,&lt;br /&gt;having clause, etc.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;7.&lt;br /&gt;Think globally when acting locally.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Any changes you make in the database to tune one SQL statement may affect the&lt;br /&gt;performance of other statements used by applications and users.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;8.&lt;br /&gt;The WHERE clause is crucial.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The following WHERE clauses would not use the index access path even if an&lt;br /&gt;index is available.&lt;br /&gt;&lt;br /&gt;e.g. Table1Col1 (Comparision Operator like &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=,)&lt;br /&gt;Table1Col2, Table1Col1 IS (NOT) NULL, Table1Col1 NOT IN (value1, value2),&lt;br /&gt;Table1Col1 != expression, Table1Col1 LIKE ‘%pattern%’, NOT Exists sub query.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;9.&lt;br /&gt;Use WHERE instead of HAVING for record filtering.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Avoid using the HAVING clause along with GROUP BY on an indexed column.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;10.&lt;br /&gt;Specify the leading index columns in WHERE clauses.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;For a composite index, the query would use the index as long as the leading&lt;br /&gt;column of the index is specified in the WHERE clause.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;11.&lt;br /&gt;Evaluate index scan vs. full table scan. (Index Only Searches Vs Large Table&lt;br /&gt;Scan, Minimize Table Passes)&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;If selecting more than 15 percent of the rows from a table, full table scan is&lt;br /&gt;usually faster than an index access path. An index is also not used if SQL&lt;br /&gt;Server has to perform implicit data conversion. When the percentage of table&lt;br /&gt;rows accessed is 15 percent or less, an index scan will work better because it&lt;br /&gt;results in multiple logical reads per row accessed, whereas a full table scan&lt;br /&gt;can read all the rows in a block in one logical read.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;12.&lt;br /&gt;Use ORDER BY for index scan.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;SQL Server optimizer will use an index scan if the ORDER BY clause is on an&lt;br /&gt;indexed column. The following query illustrates this point.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;13.&lt;br /&gt;Minimize table passes.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Usually, reducing the number of table passes in a SQL query results in better&lt;br /&gt;performance. Queries with fewer table passes mean faster queries.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;14.&lt;br /&gt;Join tables in the proper order.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Always perform the most restrictive search first to filter out the maximum&lt;br /&gt;number of rows in the early phases of a multiple table join. This way, the&lt;br /&gt;optimizer will have to work with fewer rows in the subsequent phases of join,&lt;br /&gt;improving performance.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;15.&lt;br /&gt;Redundancy is good in where condition.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Provide as much information as possible in the WHERE clause. It will help&lt;br /&gt;optimizer to clearly infer conditions.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;16.&lt;br /&gt;Keep it simple, stupid.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Very complex SQL statements can overwhelm the optimizer; sometimes writing&lt;br /&gt;multiple, simpler SQL will yield better performance than a single complex SQL&lt;br /&gt;statement.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;17.&lt;br /&gt;You can reach the same destination in different ways.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Each SQL may use a different access path and may perform differently.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;18.&lt;br /&gt;Reduce network traffic and increase throughput.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Using T-SQL blocks over Multiple SQL statements can achieve better performance&lt;br /&gt;as well as reduce network traffic. Stored Procedures are better over T-SQL&lt;br /&gt;blocks as they are stored in SQL Server and they are pre-compiled.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;19.&lt;br /&gt;Better Hardware.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Better hard ware always helps performance. SCACI drives, Raid 10 Array, Multi&lt;br /&gt;processors CPU, 64-bit operating system improves the performance by great&lt;br /&gt;amount.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;strong&gt;20.&lt;br /&gt;Avoid Cursors.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Using SQL Server cursors can result in some performance degradation in&lt;br /&gt;comparison with select statements. Try to use correlated sub query or derived&lt;br /&gt;tables if you need to perform row-by-row operations.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Ways-to-improve-SQL-performance-b1-p20.htm</guid>
	</item>
	<item>
		<title>Date format validation</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-05T11:15:38Z</pubDate>
		<description>function isDate(dtStr){&lt;br /&gt;&lt;br /&gt;    var daysInMonth = DaysArray(12)&lt;br /&gt;&lt;br /&gt;    var pos1=dtStr.indexOf(dtCh)&lt;br /&gt;&lt;br /&gt;    var pos2=dtStr.indexOf(dtCh,pos1+1)&lt;br /&gt;&lt;br /&gt;    var strMonth=dtStr.substring(0,pos1)&lt;br /&gt;&lt;br /&gt;    var strDay=dtStr.substring(pos1+1,pos2)&lt;br /&gt;&lt;br /&gt;    var strYear=dtStr.substring(pos2+1)&lt;br /&gt;&lt;br /&gt;    strYr=strYear&lt;br /&gt;&lt;br /&gt;    if (strDay.charAt(0)==&amp;quot;0&amp;quot; &amp;amp;&amp;amp; strDay.length&amp;gt;1) strDay=strDay.substring(1)&lt;br /&gt;&lt;br /&gt;    if (strMonth.charAt(0)==&amp;quot;0&amp;quot; &amp;amp;&amp;amp; strMonth.length&amp;gt;1) strMonth=strMonth.substring(1)&lt;br /&gt;&lt;br /&gt;    for (var i = 1; i &amp;lt;= 3; i++) {&lt;br /&gt;&lt;br /&gt;        if (strYr.charAt(0)==&amp;quot;0&amp;quot; &amp;amp;&amp;amp; strYr.length&amp;gt;1) strYr=strYr.substring(1)&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    month=parseInt(strMonth)&lt;br /&gt;&lt;br /&gt;    day=parseInt(strDay)&lt;br /&gt;&lt;br /&gt;    year=parseInt(strYr)&lt;br /&gt;&lt;br /&gt;    if (pos1==-1 || pos2==-1){&lt;br /&gt;&lt;br /&gt;        alert(&amp;quot;The date format should be : mm/dd/yyyy&amp;quot;)&lt;br /&gt;&lt;br /&gt;        return false&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    if (strMonth.length&amp;lt;1 || month&amp;lt;1 || month&amp;gt;12){&lt;br /&gt;&lt;br /&gt;        alert(&amp;quot;Please enter a valid month&amp;quot;)&lt;br /&gt;&lt;br /&gt;        return false&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    if (strDay.length&amp;lt;1 || day&amp;lt;1 || day&amp;gt;31 || (month==2 &amp;amp;&amp;amp; day&amp;gt;daysInFebruary(year)) || day &amp;gt; daysInMonth[month]){&lt;br /&gt;&lt;br /&gt;        alert(&amp;quot;Please enter a valid day&amp;quot;)&lt;br /&gt;&lt;br /&gt;        return false&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    if (strYear.length != 4 || year==0 || year&amp;lt;minYear || year&amp;gt;maxYear){&lt;br /&gt;&lt;br /&gt;        alert(&amp;quot;Please enter a valid 4 digit year between &amp;quot;+minYear+&amp;quot; and &amp;quot;+maxYear)&lt;br /&gt;&lt;br /&gt;        return false&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){&lt;br /&gt;&lt;br /&gt;        alert(&amp;quot;Please enter a valid date&amp;quot;)&lt;br /&gt;&lt;br /&gt;        return false&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;return true&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Date-format-validation-b1-p19.htm</guid>
	</item>
	<item>
		<title>Email validation Script</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-05T11:12:21Z</pubDate>
		<description>function validateEmail(str) {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        var at=&amp;quot;@&amp;quot;&lt;br /&gt;&lt;br /&gt;        var dot=&amp;quot;.&amp;quot;&lt;br /&gt;&lt;br /&gt;        var lat=str.indexOf(at)&lt;br /&gt;&lt;br /&gt;        var lstr=str.length&lt;br /&gt;&lt;br /&gt;        var ldot=str.indexOf(dot)&lt;br /&gt;&lt;br /&gt;        if (str.indexOf(at)==-1){&lt;br /&gt;&lt;br /&gt;           alert(&amp;quot;Invalid E-mail ID&amp;quot;)&lt;br /&gt;&lt;br /&gt;           return false&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){&lt;br /&gt;&lt;br /&gt;           alert(&amp;quot;Invalid E-mail ID&amp;quot;)&lt;br /&gt;&lt;br /&gt;           return false&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){&lt;br /&gt;&lt;br /&gt;            alert(&amp;quot;Invalid E-mail ID&amp;quot;)&lt;br /&gt;&lt;br /&gt;            return false&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         if (str.indexOf(at,(lat+1))!=-1){&lt;br /&gt;&lt;br /&gt;            alert(&amp;quot;Invalid E-mail ID&amp;quot;)&lt;br /&gt;&lt;br /&gt;            return false&lt;br /&gt;&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){&lt;br /&gt;&lt;br /&gt;            alert(&amp;quot;Invalid E-mail ID&amp;quot;)&lt;br /&gt;&lt;br /&gt;            return false&lt;br /&gt;&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         if (str.indexOf(dot,(lat+2))==-1){&lt;br /&gt;&lt;br /&gt;            alert(&amp;quot;Invalid E-mail ID&amp;quot;)&lt;br /&gt;&lt;br /&gt;            return false&lt;br /&gt;&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;&lt;br /&gt;         if (str.indexOf(&amp;quot; &amp;quot;)!=-1){&lt;br /&gt;&lt;br /&gt;            alert(&amp;quot;Invalid E-mail ID&amp;quot;)&lt;br /&gt;&lt;br /&gt;            return false&lt;br /&gt;&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;          return true                    &lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Email-validation-Script-b1-p18.htm</guid>
	</item>
	<item>
		<title>IP address to long and Long value to IP address string</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-03T08:07:39Z</pubDate>
		<description>this methods are depricated from framework 2.0 but still we need way to do this...so this is the way...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public static uint IPAddressToLong(string IPAddr)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            IPAddress oIP = IPAddress.Parse(IPAddr);&lt;br /&gt;&lt;br /&gt;            byte[] byteIP = oIP.GetAddressBytes();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            uint ip = (uint)byteIP[0] &amp;lt;&amp;lt; 24;&lt;br /&gt;&lt;br /&gt;            ip += (uint)byteIP[1] &amp;lt;&amp;lt; 16;&lt;br /&gt;&lt;br /&gt;            ip += (uint)byteIP[2] &amp;lt;&amp;lt; 8;&lt;br /&gt;&lt;br /&gt;            ip += (uint)byteIP[3];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            return ip;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        public static string LongToIPAddress(uint ipLong)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            //string ipAddress = string.Empty;&lt;br /&gt;&lt;br /&gt;            byte[] addByte = new byte[4];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            addByte[0] = (byte)((ipLong &amp;gt;&amp;gt; 24) &amp;amp; 0xFF);&lt;br /&gt;&lt;br /&gt;            addByte[1] = (byte)((ipLong &amp;gt;&amp;gt; 16) &amp;amp; 0xFF);&lt;br /&gt;&lt;br /&gt;            addByte[2] = (byte)((ipLong &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);&lt;br /&gt;&lt;br /&gt;            addByte[3] = (byte)((ipLong &amp;gt;&amp;gt; 0) &amp;amp; 0xFF);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            return addByte[0].ToString() + &amp;quot;.&amp;quot; + addByte[1].ToString() + &amp;quot;.&amp;quot; + addByte[2].ToString() + &amp;quot;.&amp;quot; + addByte[3].ToString();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/IP-address-to-long-and-Long-value-to-IP-address-string-b1-p17.htm</guid>
	</item>
	<item>
		<title>Random string and Random numbers of variable length</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-03T08:01:58Z</pubDate>
		<description>//method for random strign generation...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public static String RandomStringOfLength(int strLength)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            StringBuilder builder = new StringBuilder();            &lt;br /&gt;&lt;br /&gt;            Random random = new Random();            &lt;br /&gt;&lt;br /&gt;            char ch;&lt;br /&gt;&lt;br /&gt;            for (int i = 0; i &amp;lt; strLength; i++)&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                System.Threading.Thread.Sleep(1);&lt;br /&gt;&lt;br /&gt;                ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));&lt;br /&gt;&lt;br /&gt;                builder.Append(ch);&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return builder.ToString();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//method for random number generation...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public static String RandomNumberOfLength(int numLength)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            StringBuilder builder = new StringBuilder();            &lt;br /&gt;&lt;br /&gt;            Random random = new Random();&lt;br /&gt;&lt;br /&gt;            //char ch;&lt;br /&gt;&lt;br /&gt;            for (int i = 0; i &amp;lt; numLength; i++)&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                System.Threading.Thread.Sleep(1);&lt;br /&gt;&lt;br /&gt;                builder.Append(random.Next(0,9).ToString());&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return builder.ToString();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Random-string-and-Random-numbers-of-variable-length-b1-p16.htm</guid>
	</item>
	<item>
		<title>Working with UTF8 characters...</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-03T07:53:24Z</pubDate>
		<description>Some times situation is like we have to parse the string which has both Unicode and ASCII characters in single string, at that time Encoding functions in .NET will not be help ful,&lt;br /&gt;&lt;br /&gt;so i have created two usefull functions for that situations...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public static string GetUTF8StringFrombytes(byte[] byteVal)&lt;br /&gt;&lt;br /&gt;        {            &lt;br /&gt;&lt;br /&gt;            byte[] btOne = new byte[1];&lt;br /&gt;&lt;br /&gt;            StringBuilder sb = new StringBuilder(&amp;quot;&amp;quot;);&lt;br /&gt;&lt;br /&gt;            char uniChar;&lt;br /&gt;&lt;br /&gt;            for (int i = 0; i &amp;lt; byteVal.Length; i++)&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                btOne[0] = byteVal[i];&lt;br /&gt;&lt;br /&gt;                if (btOne[0] &amp;gt; 127)&lt;br /&gt;&lt;br /&gt;                {&lt;br /&gt;&lt;br /&gt;                    uniChar = Convert.ToChar(btOne[0]);&lt;br /&gt;&lt;br /&gt;                    sb.Append(uniChar);&lt;br /&gt;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                else&lt;br /&gt;&lt;br /&gt;                    sb.Append(Encoding.UTF8.GetString(btOne));&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return sb.ToString();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        public static byte[] GetBytesFromUTF8Chars(string strVal)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            if (strVal != string.Empty || strVal != null)&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                byte btChar;&lt;br /&gt;&lt;br /&gt;                byte[] btArr = new byte[strVal.Length * 2];&lt;br /&gt;&lt;br /&gt;                byte[] tempArr;&lt;br /&gt;&lt;br /&gt;                int arrIndex = 0;&lt;br /&gt;&lt;br /&gt;                for (int i = 0; i &amp;lt; strVal.Length; i++)&lt;br /&gt;&lt;br /&gt;                {&lt;br /&gt;&lt;br /&gt;                    btChar = (byte)strVal[i];&lt;br /&gt;&lt;br /&gt;                    if (btChar &amp;gt; 127 &amp;amp;&amp;amp; btChar &amp;lt; 256)&lt;br /&gt;&lt;br /&gt;                    {&lt;br /&gt;&lt;br /&gt;                        btArr[arrIndex] = btChar;&lt;br /&gt;&lt;br /&gt;                        arrIndex++;&lt;br /&gt;&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    else&lt;br /&gt;&lt;br /&gt;                    {&lt;br /&gt;&lt;br /&gt;                        tempArr = Encoding.UTF8.GetBytes(strVal[i].ToString());&lt;br /&gt;&lt;br /&gt;                        Array.Copy(tempArr, 0, btArr, arrIndex, tempArr.Length);&lt;br /&gt;&lt;br /&gt;                        arrIndex += tempArr.Length;&lt;br /&gt;&lt;br /&gt;                        tempArr = null;&lt;br /&gt;&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                byte[] retVal = new byte[arrIndex];&lt;br /&gt;&lt;br /&gt;                Array.Copy(btArr, 0, retVal, 0, arrIndex);&lt;br /&gt;&lt;br /&gt;                return retVal;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            else&lt;br /&gt;&lt;br /&gt;                return new byte[0];&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Working-with-UTF8-characters-b1-p15.htm</guid>
	</item>
	<item>
		<title>Credit card validation</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-03T07:37:13Z</pubDate>
		<description>&lt;h2&gt;Introduction&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Credit card validation using Regular Expressions. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Background&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;you must have some knowledge of regular expression, because it is the core part of this functionality.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;span&gt;&lt;br /&gt;&lt;pre style=&quot;margin-top: 0pt&quot;&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;// first Client side validation using JavaScript...&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;// you have to put to controls one is drop down list (for different credit &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//cards names)and other is textbox (for card number).&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//just pass two parameter to this function one is id of dropdownlist and &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//textbox.&lt;/span&gt;&lt;br /&gt;function ValidateCC(CCType, CCNum)&lt;br /&gt;{     &lt;br /&gt;var cctype= document.getElementById(CCType);                                            &lt;br /&gt;var ccnum= document.getElementById(CCNum);&lt;br /&gt;var validCCNum=false;&lt;br /&gt;var validCC=false;&lt;br /&gt;if(ccnum.value == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;)&lt;br /&gt;{      &lt;br /&gt;return false; &lt;br /&gt;}&lt;br /&gt;validCC= isValidCreditCard&lt;br /&gt;(cctype.options[cctype.selectedIndex].value,ccnum.value);&lt;br /&gt;if( validCC)&lt;br /&gt;{ &lt;br /&gt;return true; &lt;br /&gt;}&lt;br /&gt;return false; &lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;// this function is calling another function &lt;strong&gt;isValidCreditCard&lt;/strong&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//for number validation and it is here...&lt;/span&gt;&lt;br /&gt;function isValidCreditCard(type, ccnum) &lt;br /&gt;{  &lt;br /&gt;if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;Visa&amp;quot;&lt;/span&gt;)  &lt;br /&gt;var re = /^[4]([0-9]{15}$|[0-9]{12}$)/; &lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;MasterCard&amp;quot;&lt;/span&gt;)  &lt;br /&gt;var re = /^[5][1-5][0-9]{14}$/; &lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;Discover&amp;quot;&lt;/span&gt;)                                                 &lt;br /&gt;var re = /^6011-?d{4}-?d{4}-?d{4}$/;&lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;Diners Club&amp;quot;&lt;/span&gt;) &lt;br /&gt;var re = /(^30[0-5][0-9]{11}$)|(^(36|38)[0-9]{12}$)/;&lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;American Express&amp;quot;&lt;/span&gt;) &lt;br /&gt;var re = /^[34|37][0-9]{14}$/;     &lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;enRoute&amp;quot;&lt;/span&gt;) &lt;br /&gt;var re = /^(2014|2149)[0-9]{11}$/;                        &lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;JCB&amp;quot;&lt;/span&gt;) &lt;br /&gt;var re = /(^3[0-9]{15}$)|(^(2131|1800)[0-9]{11}$)/;&lt;br /&gt;if (!re.test(ccnum)) &lt;br /&gt;return false;&lt;br /&gt;ccnum = ccnum.split(&lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;-&amp;quot;&lt;/span&gt;).join(&lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;);&lt;br /&gt;var checksum = 0;&lt;br /&gt;for (var i=(2-(ccnum.length % 2)); i&amp;lt;=ccnum.length; i+=2)&lt;br /&gt;{&lt;br /&gt;checksum += parseInt(ccnum.charAt(i-1)); &lt;br /&gt;}&lt;br /&gt;for (var i=(ccnum.length % 2) + 1; i&lt;br /&gt;var digit = parseInt(ccnum.charAt(i-1)) * 2;&lt;br /&gt;if (digit &amp;lt; 10) &lt;br /&gt;{ checksum += digit; } &lt;br /&gt;else &lt;br /&gt;{ checksum += (digit-9);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;if ((checksum % 10) == 0)&lt;br /&gt;{  &lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;else &lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//now at the server side in asp.net with c#...&lt;/span&gt;&lt;br /&gt;private bool checkCCValidation()&lt;br /&gt;{ &lt;br /&gt;bool validCC = false;&lt;br /&gt;if(txtCCNumber.Text == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;validCC= isValidCreditCard(selectCCType.Value,txtCCNumber.Text.Trim());&lt;br /&gt;if( validCC)&lt;br /&gt;{  &lt;br /&gt;return true; &lt;br /&gt;}&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//this method is also calling another method and it is here..&lt;/span&gt;&lt;br /&gt;private bool isValidCreditCard(string type, string ccnum) &lt;br /&gt;{&lt;br /&gt;string regExp = &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;;                                        &lt;br /&gt;if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;Visa&amp;quot;&lt;/span&gt;)                                                &lt;br /&gt;regExp = &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;^[4]([0-9]{15}$|[0-9]{12}$)&amp;quot;&lt;/span&gt;;&lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;MasterCard&amp;quot;&lt;/span&gt;)                                                    &lt;br /&gt;regExp = &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;^[5][1-5][0-9]{14}$&amp;quot;&lt;/span&gt;;                        &lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;Discover&amp;quot;&lt;/span&gt;)                                                   &lt;br /&gt;regExp = &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;^6011-?d{4}-?d{4}-?d{4}$&amp;quot;&lt;/span&gt;;&lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;Diners Club&amp;quot;&lt;/span&gt;) &lt;br /&gt;regExp = &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;(^30[0-5][0-9]{11}$)|(^(36|38)[0-9]{12}$)&amp;quot;&lt;/span&gt;;&lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;American Express&amp;quot;&lt;/span&gt;) &lt;br /&gt;regExp = &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;^[34|37][0-9]{14}$&amp;quot;&lt;/span&gt;;     &lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;enRoute&amp;quot;&lt;/span&gt;) &lt;br /&gt;regExp = &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;^(2014|2149)[0-9]{11}$&amp;quot;&lt;/span&gt;;                        &lt;br /&gt;else if (type == &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;JCB&amp;quot;&lt;/span&gt;) &lt;br /&gt;regExp = &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;(^3[0-9]{15}$)|(^(2131|1800)[0-9]{11}$)&amp;quot;&lt;/span&gt;;&lt;br /&gt;if (!Regex.IsMatch(ccnum,regExp)) &lt;br /&gt;return false;&lt;br /&gt;string[] tempNo = ccnum.Split(&#039;-&#039;);&lt;br /&gt;ccnum = String.Join(&lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;, tempNo);&lt;br /&gt;int checksum = 0;&lt;br /&gt;for (int i = (2-(ccnum.Length % 2)); i &amp;lt;= ccnum.Length; i += 2) &lt;br /&gt;{&lt;br /&gt;checksum += Convert.ToInt32(ccnum[i-1].ToString());&lt;br /&gt;}&lt;br /&gt;int digit = 0;&lt;br /&gt;for (int i = (ccnum.Length % 2) + 1; i &amp;lt; ccnum.Length; i += 2)&lt;br /&gt;{&lt;br /&gt;digit = 0;&lt;br /&gt;digit = Convert.ToInt32(ccnum[i-1].ToString()) * 2;&lt;br /&gt;if (digit &amp;lt; 10)&lt;br /&gt;{ checksum += digit; }&lt;br /&gt;else&lt;br /&gt;{ checksum += (digit - 9); }&lt;br /&gt;}&lt;br /&gt;if ((checksum % 10) == 0)&lt;br /&gt;return true;&lt;br /&gt;else &lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//so that is the end of simple way of validating credit card, without using &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//any third party controls..so enjoy...&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Credit-card-validation-b1-p14.htm</guid>
	</item>
	<item>
		<title>"Using" keyword in Data Access Base classes..</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-03T07:26:52Z</pubDate>
		<description>&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font size=&quot;3&quot;&gt;&lt;strong&gt;&lt;font size=&quot;0&quot;&gt;this example demonstrates use of &amp;quot;Using&amp;quot; keyword which disposes all resources used inside it and&lt;br /&gt;&lt;br /&gt;in Data Access base classes we don&#039;t have to worried about connection and adapter ispose, they will&lt;br /&gt;&lt;br /&gt;be disposed automatically immediatly after use..&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;internal DataTable GetNetworkSettingsByNetworkID(int networkID)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                using (Connection = new MySqlConnection(connectionString))&lt;br /&gt;&lt;br /&gt;                {&lt;br /&gt;&lt;br /&gt;                    using (MySqlCommand command = new MySqlCommand())&lt;br /&gt;&lt;br /&gt;                    {&lt;br /&gt;&lt;br /&gt;                        command.CommandText = SQL_GET_NETWORKSETTINGS_BY_NETWORKID;&lt;br /&gt;&lt;br /&gt;                        command.CommandType = CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;                        command.Connection = Connection;&lt;br /&gt;&lt;br /&gt;                        command.Parameters.Add(new MySqlParameter(&amp;quot;?_NetworkID&amp;quot;, MySqlDbType.Int32));&lt;br /&gt;&lt;br /&gt;                        command.Parameters[0].Value = networkID;&lt;br /&gt;&lt;br /&gt;                        using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter(command))&lt;br /&gt;&lt;br /&gt;                        {&lt;br /&gt;&lt;br /&gt;                            using (DataTable dtNetworkSettings = new DataTable())&lt;br /&gt;&lt;br /&gt;                            {&lt;br /&gt;&lt;br /&gt;                                dataAdapter.Fill(dtNetworkSettings);&lt;br /&gt;&lt;br /&gt;                                return dtNetworkSettings;&lt;br /&gt;&lt;br /&gt;                            }&lt;br /&gt;&lt;br /&gt;                        }&lt;br /&gt;&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                PacketUtils.WriteLogError(ex, &amp;quot;NetworkDA::GetNetworkSettingsByNetworkID&amp;quot;);&lt;br /&gt;&lt;br /&gt;                throw ex;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            finally&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                if (Connection != null)&lt;br /&gt;&lt;br /&gt;                {&lt;br /&gt;&lt;br /&gt;                    if (Connection.State == ConnectionState.Open)&lt;br /&gt;&lt;br /&gt;                        Connection.Close();&lt;br /&gt;&lt;br /&gt;                    Connection.Dispose();&lt;br /&gt;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Using-keyword-in-Data-Access-Base-classes-b1-p13.htm</guid>
	</item>
	<item>
		<title>Url rewritting in some simple steps...</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-03T07:14:13Z</pubDate>
		<description>&lt;span&gt;&lt;br /&gt;&lt;h2&gt;Introduction&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Sometimes, we want that our web url will not contain any&lt;br /&gt;&amp;quot;?&amp;quot;,&amp;quot;&amp;amp;&amp;quot; or other kind of non readable symbols, but the question is&lt;br /&gt;that how to remove them from the browser&#039;s address bar, but that&lt;br /&gt;information is very essential for us because they are query parameters&lt;br /&gt;for us.     So it is like we are hiding information of query string&lt;br /&gt;from the user by displaying some nice and readable contains, but with&lt;br /&gt;at server side we want our query parameters back. So that is called&lt;br /&gt;&amp;quot;URL rewriting&amp;quot;. Don&#039;t worry it is not a difficult task.  &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Background&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Before that, we have to have some knowledge of how the requests&lt;br /&gt;are processed on ASP.NET server? Remember that when any request is&lt;br /&gt;coming it has to pass through  &amp;quot;&lt;strong&gt;Application_BeginRequest()&lt;/strong&gt;&amp;quot; method in &lt;strong&gt;Global.asax&lt;/strong&gt; file.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;This is that access point of each and every requests those are coming&lt;br /&gt;to our application.So cheers it is that point where we have to work for&lt;br /&gt;URL rewriting.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;span&gt;&lt;br /&gt;&lt;pre style=&quot;margin-top: 0pt&quot;&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;// Write this method prototype like this,&lt;/span&gt;&lt;br /&gt;void Application_BeginRequest(object sender, EventArgs e)&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;// write structure of code like this... &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;// First get the url of the request,&lt;/span&gt;&lt;br /&gt;string absoluteUrl = Request.Url.AbsolutePath.ToString();&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//then search for the specific page into that url of request,(means you can &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//rewrite the url for some speific pages only. &lt;/span&gt;&lt;br /&gt;if (absoluteUrl.Contains(&lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;/test/default.aspx&amp;quot;&lt;/span&gt;))&lt;br /&gt;{ &lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//now search for some redable query string parameter like you have embedded&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//url link like this...http://test.com/test/default.aspx?mypageid=33 &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//here instade of this we can write like..  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//http://test.com/test/default.aspx/&lt;strong&gt;MyPage33&lt;/strong&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//so you can see we have removed unreadable and ugly codes from url.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;// now how to handle this and converting this back to our real information.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//find the location of last &amp;quot;/&amp;quot; character because from that &amp;quot;MyPage33&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//word is starting. &lt;/span&gt;&lt;br /&gt;string pageid = absoluteUrl.Substring&lt;br /&gt;(absoluteUrl.LastIndexOf(&#039;/&#039;) + 1).Trim();&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//now skip first 5 characters because they are &amp;quot;MyPage&amp;quot;.&lt;/span&gt;&lt;br /&gt;pageid = pageid.Substring(6); &lt;span class=&quot;cs-comment&quot;&gt;//this will give &amp;quot;33&amp;quot;.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;// now generate the original Url which is required by our application. &lt;/span&gt;&lt;br /&gt;string path = &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;~/test/default.aspx?mypageid=&amp;quot;&lt;/span&gt; + pageid;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//now redirect to the target page, &lt;/span&gt;&lt;br /&gt;Response.Redirect(path);&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//Bengo!!!! &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cs-comment&quot;&gt;//We have successfully done with Url rewriting.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/Url-rewritting-in-some-simple-steps-b1-p12.htm</guid>
	</item>
	<item>
		<title>FTP Operation in just 4-5 lines...</title>
		<category>Patel&#039;s Lab</category>
		<pubDate>2007-12-03T07:10:50Z</pubDate>
		<description>&lt;p&gt;&lt;br /&gt;&lt;span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Introduction&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;This article will enable you to write FTP operation in just 5 minutes...&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;We&lt;br /&gt;know that FTP same as direcotry structure which we have on our system,&lt;br /&gt;but the difference is that FTP directory is located at some other place.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;So when you upload afile you are transfering one file from one place to&lt;br /&gt;another, just like in Unix programming, if we want to copy one file&lt;br /&gt;from one place to another we&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;span&gt;&lt;br /&gt;&lt;pre style=&quot;margin-top: 0pt&quot;&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;// Just Rename File name and FTP location that you want to upload or download.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//Generate the File name which you want to upload on the FTP... &lt;/span&gt;&lt;br /&gt;&lt;strong&gt;string &lt;strong&gt;ftpFilename&lt;/strong&gt; = ftpServer + FileName;&lt;/strong&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//Create a Object of class WebClient.. &lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;strong&gt;WebClient&lt;/strong&gt; client = &lt;span class=&quot;cpp-keyword&quot;&gt;new&lt;/span&gt; WebClient();&lt;/strong&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//Give the Credincials which will help you to enter into the FTP..&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;client.&lt;strong&gt;Credentials&lt;/strong&gt; = &lt;span class=&quot;cpp-keyword&quot;&gt;new&lt;/span&gt; &lt;strong&gt;NetworkCredential&lt;/strong&gt;(loginName, ftpPwd);&lt;/strong&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//Now use .&lt;strong&gt;UploadFile&lt;/strong&gt; Method of WebClient Object to upload the file,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-keyword&quot;&gt;//this&lt;/span&gt; method will &lt;span class=&quot;cpp-keyword&quot;&gt;return&lt;/span&gt; response from the FTP server which you can use as, &lt;br /&gt;//result of FTP operation.. &lt;strong&gt;&lt;br /&gt;responseArray = client.&lt;strong&gt;UploadFile&lt;/strong&gt;(ftpFilename, filetobeUploaded); &lt;/strong&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//here you have to pass full path of FTP directory with filename included as&lt;/span&gt;&lt;br /&gt;// &lt;strong&gt;ftpFilename, &lt;/strong&gt;like &lt;span class=&quot;cpp-keyword&quot;&gt;if&lt;/span&gt; you want to upload file to ftp:&lt;span class=&quot;cpp-comment&quot;&gt;//simpleftp.com then&lt;/span&gt;&lt;br /&gt;//use &lt;span class=&quot;cpp-keyword&quot;&gt;this&lt;/span&gt; kind of structure..&lt;br /&gt;//ftpFilename = &lt;span class=&quot;cpp-string&quot;&gt;&amp;quot;ftp://simpleftp.com/test.txt&amp;quot;&lt;/span&gt;;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//and in the &#039;filetobeUploaded&#039; give name of your file to be uploaded..&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//same way you can download the file by using .downloadfile method of the &lt;br /&gt;&lt;/span&gt;//Webclient &lt;span class=&quot;cpp-keyword&quot;&gt;class&lt;/span&gt; Object.&lt;br /&gt;&lt;span class=&quot;cpp-comment&quot;&gt;//so enjoy the FTP operation in just 5 minutes..&lt;/span&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;</description>
		<guid>http://patelslab.yourliveblog.com/Patel-s-Lab-b1/FTP-Operation-in-just-4-5-lines-b1-p11.htm</guid>
	</item>
	</channel>
</rss>