<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tech Insight ! &#187; SQL server 2005</title>
	<atom:link href="http://techinsight.dhanashree.com/tag/sql-server-2005/feed/" rel="self" type="application/rss+xml" />
	<link>http://techinsight.dhanashree.com</link>
	<description>Technical blog on ASP.Net, PHP, Web Development, Web hosting , Database Programming</description>
	<lastBuildDate>Fri, 12 Aug 2011 07:26:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to make SQL Server 2005 database empty using cursor &amp; sys.objects (Delete All Tables, stored procedures, views &amp; UDF’s)</title>
		<link>http://techinsight.dhanashree.com/how-to-make-sql-server-2005-database-empty-using-cursor-sys-objects-delete-all-tables-stored-procedures-views-udf%e2%80%99s/</link>
		<comments>http://techinsight.dhanashree.com/how-to-make-sql-server-2005-database-empty-using-cursor-sys-objects-delete-all-tables-stored-procedures-views-udf%e2%80%99s/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 09:17:51 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[SQL server 2005]]></category>
		<category><![CDATA[DBMS]]></category>
		<category><![CDATA[SQL server]]></category>

		<guid isPermaLink="false">http://techinsight.dhanashree.com/how-to-make-sql-server-2005-database-empty-using-cursor-sys-objects-delete-all-tables-stored-procedures-views-udf%e2%80%99s/</guid>
		<description><![CDATA[Understanding sys.objects:
Sys.objects is a system VIEW in SQL Server 2005, for each SQL database there is a separate sys.object view which gets stored within databse itself.
Using Sys.objects returns list of all database objects and its types, type can be either of given below:
DB OBJECT TYPES

F     FOREIGN_KEY_CONSTRAINT
IT    INTERNAL_TABLE
PK    PRIMARY_KEY_CONSTRAINT
S     SYSTEM_TABLE
SQ    SERVICE_QUEUE
U     USER_TABLE
V     VIEW
How to DELETE all User Tables , [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Understanding <span style="text-decoration: underline;">s</span><em><span style="text-decoration: underline;">ys.objects</span></em></strong>:</p>
<p><strong><em>Sys.objects</em></strong> is a system VIEW in SQL Server 2005, for each SQL database there is a separate <strong>sys.object </strong>view which gets stored within databse itself.</p>
<p>Using <strong><em>Sys.objects</em></strong> returns list of all database objects and its types, type can be either of given below:</p>
<p><span style="text-decoration: underline;"><strong>DB OBJECT TYPES<br />
</strong></span></p>
<p>F     FOREIGN_KEY_CONSTRAINT</p>
<p>IT    INTERNAL_TABLE</p>
<p>PK    PRIMARY_KEY_CONSTRAINT</p>
<p>S     SYSTEM_TABLE</p>
<p>SQ    SERVICE_QUEUE</p>
<p>U     USER_TABLE</p>
<p>V     VIEW</p>
<p><span style="text-decoration: underline;"><strong><em>How to DELETE all User Tables , stored procedures , UDF&#8217;s and Views using cursor<br />
</em></strong></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">Use</span> [database name]<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">declare</span> @q <span style="color: blue;">as</span><br />
<span style="color: blue;">nvarchar</span><span style="color: gray;">(</span><span style="color: fuchsia;">max</span><span style="color: gray;">)<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">declare</span> @name <span style="color: blue;">nvarchar</span><span style="color: gray;">(</span><span style="color: fuchsia;">max</span><span style="color: gray;">);<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">declare</span> @type <span style="color: blue;">nvarchar</span><span style="color: gray;">(</span><span style="color: fuchsia;">max</span><span style="color: gray;">);<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">declare</span> cur <span style="color: blue;">cursor</span><br />
<span style="color: blue;">for<span style="color: #000000;"> </span>select name <span style="color: #000000;"><span style="color: gray;">,</span><span style="color: blue;">type from <span style="color: #008000;">sys.objects <span style="color: #0000ff;">where type <span style="color: #000000;"><span style="color: gray;">in(</span><span style="color: red;">&#8216;p&#8217;</span><span style="color: gray;">,</span><span style="color: red;">&#8216;fn&#8217;</span><span style="color: gray;">,</span><span style="color: red;">&#8216;v&#8217;</span><span style="color: gray;">,</span><span style="color: red;">&#8216;u&#8217;</span><span style="color: gray;">);</span></span></span></span></span></span></span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">open</span> cur<span style="color: gray;">;<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">fetch</span> next <span style="color: blue;">from</span> cur <span style="color: blue;">into</span> @name<span style="color: gray;">,</span>@type </span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: #0000ff;">while <span style="color: #ff00ff;">@@fetch_status <span style="color: #000000;"><span style="color: gray;">=</span> 0</span></span></span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: #0000ff;"><span style="color: #ff00ff;"><span style="color: #000000;"><span style="color: #0000ff;">begin</span></span></span></span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span><span style="color: gray;">(</span>@type<span style="color: gray;">=</span><span style="color: red;">&#8216;p&#8217;</span><span style="color: gray;">)<br />
</span></span></p>
<p><span style="color: blue; font-family: Courier New; font-size: 10pt;">begin<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">set</span> @q<span style="color: gray;">=</span>N<span style="color: red;">&#8216;drop procedure &#8216;</span><span style="color: red;"> </span><span style="color: gray;">+</span> @name<span style="color: gray;">;<br />
</span></span></p>
<p><span style="color: blue; font-family: Courier New; font-size: 10pt;">end<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span><span style="color: gray;">(</span>@type<span style="color: gray;">=</span><span style="color: red;">&#8216;fn&#8217;</span><span style="color: gray;">)<br />
</span></span></p>
<p><span style="color: blue; font-family: Courier New; font-size: 10pt;">begin</span></p>
<p><span style="color: blue; font-family: Courier New; font-size: 10pt;"><span style="color: #000000;"><span style="color: blue;">set</span> @q<span style="color: gray;">=</span>N<span style="color: red;">&#8216;drop function &#8216; <span style="color: #000000;"><span style="color: gray;">+</span> @name<span style="color: gray;">;</span></span></span></span></span></p>
<p><span style="color: blue; font-family: Courier New; font-size: 10pt;">end<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span><span style="color: gray;">(</span>@type<span style="color: gray;">=</span><span style="color: red;">&#8216;v&#8217;</span><span style="color: gray;">)<br />
</span></span></p>
<p><span style="color: blue; font-family: Courier New; font-size: 10pt;">begin<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">set</span> @q<span style="color: gray;">=</span>N<span style="color: red;">&#8216;drop view &#8216;</span><span style="color: red;"> </span><span style="color: gray;">+</span> @name<span style="color: gray;">;<br />
</span></span></p>
<p><span style="color: blue; font-family: Courier New; font-size: 10pt;">end<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span><span style="color: gray;">(</span>@type<span style="color: gray;">=</span><span style="color: red;">&#8216;u&#8217;</span><span style="color: gray;">)<br />
</span></span></p>
<p><span style="color: blue; font-family: Courier New; font-size: 10pt;">begin<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">set</span> @q<span style="color: gray;">=</span>N<span style="color: red;">&#8216;drop table &#8216;</span><span style="color: red;"> </span><span style="color: gray;">+</span> @name<span style="color: gray;">;<br />
</span></span></p>
<p><span style="color: blue; font-family: Courier New; font-size: 10pt;">end<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">exec</span><span style="color: blue;"> </span><span style="color: maroon;">sp_executesql</span> @q<span style="color: gray;">;<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">fetch</span> next <span style="color: blue;">from</span> cur <span style="color: blue;">into</span> @name<span style="color: gray;">,</span>@type<br />
</span></p>
<p><span style="color: blue; font-family: Courier New; font-size: 10pt;">end<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">close</span> cur<span style="color: gray;">;<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">deallocate</span> cur<span style="color: gray;">;</span></span></p>
<p><span style="font-family: Calibri; font-size: 15px; color: #ff0000;">NOTE<span style="mso-spacerun: yes;"> </span>:</span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/how-to-make-sql-server-2005-database-empty-using-cursor-sys-objects-delete-all-tables-stored-procedures-views-udf%e2%80%99s/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Quick DBMS reference: Single line definitions of important SQL Server terms</title>
		<link>http://techinsight.dhanashree.com/quick-dbms-reference-single-line-definitions-of-important-sql-server-terms-2/</link>
		<comments>http://techinsight.dhanashree.com/quick-dbms-reference-single-line-definitions-of-important-sql-server-terms-2/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 09:36:40 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[SQL server 2005]]></category>
		<category><![CDATA[DBMS]]></category>

		<guid isPermaLink="false">http://techinsight.dhanashree.com/?p=188</guid>
		<description><![CDATA[Normalization: is a process of organizing data and minimizing redundancy 
De-normalization: is a technique to move from higher to lower normal forms of database modeling in order to speed up database access.
Stored Procedure: is a named group of T-SQL statements which can be created and stored in Database as an object.
Primary Key: is a unique [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Normalization: </strong>is a process of organizing data and minimizing redundancy<strong> </strong></p>
<p><strong>De-normalization: </strong>is a technique to move from higher to lower normal forms of database modeling in order to speed up database access.</p>
<p><strong>Stored Procedure: </strong>is a named group of T-SQL statements which can be created and stored in Database as an object.</p>
<p><strong>Primary Key: </strong>is a unique identifier of a row in a DB table, [it can’t be NULL]</p>
<p><strong>Unique key: </strong>forces uniqueness to a respective table column, [it can be NULL]</p>
<p><strong>Foreign Key: </strong>a foreign key in 1 table refers to the primary key in other table, Used to force referential integrity.</p>
<p><strong>Inner join: </strong>exists in both tables</p>
<p><strong>Left Outer join: </strong>all records from left side table + matched rows from right side table (totals number of rows will be same as left table)</p>
<p><strong>Right Outer join: </strong>all records from right side table + matched rows from left side table (totals number of rows will be same as right table), it’s a mirror image of left outer join</p>
<p><strong>Full Outer join: </strong>all records from left side table + all records from right side table, weather matched or not</p>
<p><strong>Cross join: </strong>returns [left table rows * right table rows], a Cartesian product of both tables</p>
<p><strong>Self join: </strong>when table joins to itself using diff aliases to avoid confusion</p>
<p><strong>Union: </strong>selects only distinct records from both tables</p>
<p><strong>Union all: </strong>selects all records from both tables</p>
<p><strong>View: </strong>is a subset of a table, can be used to retrieve data, insert or Update data. Can contain multiple select statements inside</p>
<p><strong>Trigger: </strong>A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or UPDATE) occurs.</p>
<p><strong>Cursor: </strong>is a database object used to loop trough records on row by row bases.</p>
<p><strong>Index: </strong>pointers to data records, represents structure of how data get stored physically in a table</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="319" valign="top"><strong>Clustered index</strong></td>
<td width="319" valign="top"><strong>Non clustered index</strong></td>
</tr>
<tr>
<td width="319" valign="top">Reorders physical data stored in table</td>
<td width="319" valign="top">It contains pointers to data rows</td>
</tr>
<tr>
<td width="319" valign="top">A table can have Only 1 clustered index</td>
<td width="319" valign="top">A table can have one OR many    non-clustered index</td>
</tr>
<tr>
<td width="319" valign="top">Leaf nodes contains data</td>
<td width="319" valign="top">Leaf nodes contains reference to data</td>
</tr>
</tbody>
</table>
<p><strong> </strong></p>
<p><strong>Linked server: </strong>is a concept of adding other remote server to a group to query DB’s of both servers together</p>
<p><strong>Collation: set of rules that determines how data stores &amp; compares in database</strong><strong> </strong></p>
<p><strong>Collation types: case sensitive, accent sensitive, kana sensitive, width sensitive</strong></p>
<p><strong>Data ware housing: </strong></p>
<ol>
<li>Record should Never delete from DB</li>
<li>All records must be linked</li>
<li>Once committed records should be read-only</li>
<li>All changes made must be tracked with time</li>
</ol>
<p><strong>User defined function (UDF): </strong>is a bunch of T-SQL statements which accepts 0 or more parameters and returns a scalar data value or table.</p>
<p><strong>DDL:</strong> data definition language – e.g. <strong>TRUNCATE</strong> command is a DDL command</p>
<p><strong>DML:</strong> data manipulation language – e.g. <strong>INSERT</strong>, <strong>UPDATE</strong> &amp; <strong>DELETE</strong> are DML commands</p>
<p><span style="font-family: Calibri; font-size: 15px; color: #ff0000;">NOTE<span style="mso-spacerun: yes;"> </span>:</span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/quick-dbms-reference-single-line-definitions-of-important-sql-server-terms-2/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Writing recursive queries in SQL server 2005 using Common table expression (CTE)</title>
		<link>http://techinsight.dhanashree.com/writing-recursive-queries-in-sql-server-2005-using-common-table-expression-cte/</link>
		<comments>http://techinsight.dhanashree.com/writing-recursive-queries-in-sql-server-2005-using-common-table-expression-cte/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 13:54:32 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[SQL server 2005]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=24</guid>
		<description><![CDATA[
with cte (empID,manID,depth,hierarchy) as
 (
 select e.employeeID,e.managerID ,1 , cast(e.employeeID as nvarchar(max))as hierarchy
 from humanresources.Employee as e
 where managerID is null


 union all


 select emp.employeeID,emp.managerID ,depth+1  , hierarchy + &#8216;/&#8217; +cast(emp.employeeID as nvarchar(max)) as hierarchy
 from humanresources.Employee emp 
 inner join cte 
 on emp.managerID=cte.empID
 )


select * from cte order by depth



NOTE :
If you [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"><br />
with </span><span style="font-size:10pt;font-family:'Courier New';">cte <span style="color:gray;">(</span>empID<span style="color:gray;">,</span>manID<span style="color:gray;">,</span>depth<span style="color:gray;">,</span>hierarchy<span style="color:gray;">)</span> <span style="color:blue;">as</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:gray;font-family:'Courier New';"> (</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"> select </span><span style="font-size:10pt;font-family:'Courier New';">e<span style="color:gray;">.</span>employeeID<span style="color:gray;">,</span>e<span style="color:gray;">.</span>managerID <span style="color:gray;">,</span>1 <span style="color:gray;">,</span> <span style="color:fuchsia;">cast</span><span style="color:gray;">(</span>e<span style="color:gray;">.</span>employeeID <span style="color:blue;">as</span> <span style="color:blue;">nvarchar</span><span style="color:gray;">(</span><span style="color:fuchsia;">max</span><span style="color:gray;">))</span><span style="color:blue;">as</span> hierarchy</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"> from </span><span style="font-size:10pt;font-family:'Courier New';">humanresources<span style="color:gray;">.</span>Employee <span style="color:blue;">as </span>e</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"> where </span><span style="font-size:10pt;font-family:'Courier New';">managerID <span style="color:gray;">is</span> <span style="color:gray;">null</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-family:'Courier New';color:#0000ff;"><span style="color:#008000;"><br />
</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"> union</span><span style="font-size:10pt;color:blue;font-family:'Courier New';"> </span><span style="font-size:10pt;font-family:'Courier New';"><span style="color:gray;">all</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:'Courier New';"><span style="color:gray;"><br />
</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"> select </span><span style="font-size:10pt;font-family:'Courier New';">emp<span style="color:gray;">.</span>employeeID<span style="color:gray;">,</span>emp<span style="color:gray;">.</span>managerID <span style="color:gray;">,</span>depth<span style="color:gray;">+</span>1  <span style="color:gray;">,</span> hierarchy <span style="color:gray;">+</span><span style="color:gray;"> </span><span style="color:red;">&#8216;/&#8217;</span> <span style="color:gray;">+</span><span style="color:fuchsia;">cast</span><span style="color:gray;">(</span>emp<span style="color:gray;">.</span>employeeID <span style="color:blue;">as</span><span style="color:blue;"> </span><span style="color:blue;">nvarchar</span><span style="color:gray;">(</span><span style="color:fuchsia;">max</span><span style="color:gray;">))</span> <span style="color:blue;">as</span> hierarchy</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"> from </span><span style="font-size:10pt;font-family:'Courier New';">humanresources<span style="color:gray;">.</span>Employee emp </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:gray;font-family:'Courier New';"> inner</span><span style="font-size:10pt;color:gray;font-family:'Courier New';"> </span><span style="font-size:10pt;font-family:'Courier New';"><span style="color:gray;">join</span> cte </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:'Courier New';"> on </span><span style="font-size:10pt;font-family:'Courier New';">emp<span style="color:gray;">.</span>managerID<span style="color:gray;">=</span>cte<span style="color:gray;">.</span>empID</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:gray;font-family:'Courier New';"> )</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:gray;font-family:'Courier New';"><br />
</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;color:blue;line-height:115%;font-family:'Courier New';">select</span><span style="font-size:10pt;line-height:115%;font-family:'Courier New';"> <span style="color:gray;">*</span><span style="color:gray;"> </span><span style="color:blue;">from</span> cte <span style="color:blue;">order </span><span style="color:blue;">by</span> depth</span></p>
<p><span style="text-decoration: underline;"><strong><em><br />
</em></strong></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><span style="font-family: Calibri;"><br />
NOTE<span style="mso-spacerun: yes;"> </span>:</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/writing-recursive-queries-in-sql-server-2005-using-common-table-expression-cte/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Storing and Retrieving image in SQL server 2005 &amp; asp.net using large value data type &amp; HTTP handler</title>
		<link>http://techinsight.dhanashree.com/storing-and-retrieving-image-in-sql-server-2005-asp-net-using-large-value-data-type-http-handler/</link>
		<comments>http://techinsight.dhanashree.com/storing-and-retrieving-image-in-sql-server-2005-asp-net-using-large-value-data-type-http-handler/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 13:51:13 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[C#.net]]></category>
		<category><![CDATA[SQL server 2005]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>
		<category><![CDATA[SQL server]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=22</guid>
		<description><![CDATA[ASPX page :
&#60;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&#62;
&#60;div style=&#8221;padding: 200px;&#8221;&#62;
&#60;asp:Image ID=&#8221;imagebox&#8221; runat=&#8221;server&#8221; ImageUrl=&#8221;~/sql-image-store/image-handler.ashx&#8221; /&#62;
&#60;/div&#62;
&#60;/form&#62;
Handler code: image-handler.ashx 
&#60;%@ WebHandler Language=&#8221;C#&#8221; Class=&#8221;image_handler&#8221; %&#62;
using System;
using System.Web;
using System.IO;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
public class image_handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string xStrCon = System.Configuration.ConfigurationManager.ConnectionStrings["conStrImage"].ConnectionString;
SqlConnection xCon = new SqlConnection(xStrCon);
xCon.Open();
SqlCommand xCom = new SqlCommand(&#8220;select * from images where&#8221;, xCon);
SqlDataAdapter xAda = new SqlDataAdapter(xCom);
DataSet ds = new [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste"><strong><a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">ASPX</a> page :</strong></div>
<div>&lt;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&gt;</div>
<div id="_mcePaste">&lt;div style=&#8221;padding: 200px;&#8221;&gt;</div>
<div id="_mcePaste">&lt;asp:Image ID=&#8221;imagebox&#8221; runat=&#8221;server&#8221; ImageUrl=&#8221;~/sql-image-store/image-handler.ashx&#8221; /&gt;</div>
<div id="_mcePaste">&lt;/div&gt;</div>
<div id="_mcePaste">&lt;/form&gt;</div>
<p><strong>Handler code: </strong>image-handler.ashx<strong> </strong></p>
<p>&lt;%@ WebHandler Language=&#8221;C#&#8221; Class=&#8221;image_handler&#8221; %&gt;</p>
<p>using System;</p>
<p>using System.Web;</p>
<p>using System.IO;</p>
<p>using System.Data;</p>
<p>using System.Data.Sql;</p>
<p>using System.Data.SqlClient;</p>
<p>using System.Configuration;</p>
<p>public class image_handler : IHttpHandler</p>
<p>{</p>
<p>public void ProcessRequest(HttpContext context)</p>
<p>{</p>
<p>string xStrCon = System.Configuration.ConfigurationManager.ConnectionStrings["conStrImage"].ConnectionString;</p>
<p>SqlConnection xCon = new SqlConnection(xStrCon);</p>
<p>xCon.Open();</p>
<p>SqlCommand xCom = new SqlCommand(&#8220;select * from images where&#8221;, xCon);</p>
<p>SqlDataAdapter xAda = new SqlDataAdapter(xCom);</p>
<p>DataSet ds = new DataSet();</p>
<p>xAda.Fill(ds);</p>
<p>// Image processing starts</p>
<p>byte[] bytImage = ReadFile(context.Server.MapPath(&#8220;banner.JPG&#8221;));</p>
<p>xCom.CommandText = &#8220;insert into images values(2,&#8217;kensington&#8217;,@imagedata)&#8221;;</p>
<p>xCom.Parameters.Add(new SqlParameter(&#8220;@imagedata&#8221;, (object)bytImage));</p>
<p>xCon.Close();</p>
<p>//Display image from SQL server</p>
<p>byte[] imageData = (byte[])ds.Tables[0].Rows[0][2];</p>
<p>context.Response.Clear();</p>
<p>context.Response.ContentType = &#8220;image/JPEG&#8221;;</p>
<p>context.Response.OutputStream.Write(imageData, 0, imageData.Length);</p>
<p>}</p>
<p>byte[] ReadFile(string sPath)</p>
<p>{</p>
<p>//Initialize byte array with a null value initially.</p>
<p>byte[] data = null;</p>
<p>//Use FileInfo object to get file size.</p>
<p>FileInfo fInfo = new FileInfo(sPath);</p>
<p>long numBytes = fInfo.Length;</p>
<p>//Open FileStream to read file</p>
<p>FileStream fStream = new FileStream(sPath, FileMode.Open, FileAccess.Read);</p>
<p>//Use BinaryReader to read file stream into byte array.</p>
<p>BinaryReader br = new BinaryReader(fStream);</p>
<p>//When you use BinaryReader, you need to supply number of bytes to read from file.</p>
<p>//In this case we want to read entire file. So supplying total number of bytes.</p>
<p>data = br.ReadBytes((int)numBytes);</p>
<p>return data;</p>
<p>}</p>
<p>public bool IsReusable</p>
<p>{</p>
<p>get</p>
<p>{</p>
<p>return false;</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p><span style="text-decoration: underline;"><strong><em><br />
</em></strong></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><span style="font-family: Calibri;"><br />
NOTE<span style="mso-spacerun: yes;"> </span>:</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/storing-and-retrieving-image-in-sql-server-2005-asp-net-using-large-value-data-type-http-handler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Import Excel data into SQL Server 2005 table using distributed queries</title>
		<link>http://techinsight.dhanashree.com/import-excel-data-into-sql-server-2005-table-using-distributed-queries/</link>
		<comments>http://techinsight.dhanashree.com/import-excel-data-into-sql-server-2005-table-using-distributed-queries/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 13:46:54 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[SQL server 2005]]></category>
		<category><![CDATA[SQL server]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=19</guid>
		<description><![CDATA[/*SQL server configuration settings */
exec sp_configure
sp_configure &#8217;show advanced options&#8217;, 1
reconfigure
exec sp_configure &#8216;Ad Hoc Distributed Queries&#8217;, 1
reconfigure
/*Excel import into sql table  using distributed query*/
select * into XLimport from
openrowset(&#8216;Microsoft.Jet.OLEDB.4.0&#8242;,
&#8216;Excel 8.0;Database=C:\Documents and Settings\Administrator\Desktop\filename.xls&#8217;
,[Sheet1$])
select * from XLimport



NOTE :
If you are in need of any Web Development feel free to Inquire us . Dhanashree Inc. Expertise in Asp.net Development, [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste">/*SQL server configuration settings */</div>
<div id="_mcePaste">exec sp_configure</div>
<div id="_mcePaste">sp_configure &#8217;show advanced options&#8217;, 1</div>
<div id="_mcePaste">reconfigure</div>
<div id="_mcePaste">exec sp_configure &#8216;Ad Hoc Distributed Queries&#8217;, 1</div>
<div id="_mcePaste">reconfigure</div>
<div id="_mcePaste">/*Excel import into sql table  using distributed query*/</div>
<div id="_mcePaste">select * into XLimport from</div>
<div id="_mcePaste">openrowset(&#8216;Microsoft.Jet.OLEDB.4.0&#8242;,</div>
<div id="_mcePaste">&#8216;Excel 8.0;Database=C:\Documents and Settings\Administrator\Desktop\filename.xls&#8217;</div>
<div id="_mcePaste">,[Sheet1$])</div>
<div id="_mcePaste">select * from XLimport</div>
<p><span style="text-decoration: underline;"><strong><em><br />
</em></strong></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><span style="font-family: Calibri;"><br />
NOTE<span style="mso-spacerun: yes;"> </span>:</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/import-excel-data-into-sql-server-2005-table-using-distributed-queries/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

