<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Software Code Help - SQL Server</title>
    <link>http://blog.softwarecodehelp.com/</link>
    <description>Blog</description>
    <language>en-us</language>
    <copyright>SoftwareCodeHelp</copyright>
    <lastBuildDate>Tue, 20 Oct 2009 06:10:59 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>rajshekher@gmail.com</managingEditor>
    <webMaster>rajshekher@gmail.com</webMaster>
    <item>
      <trackback:ping>http://blog.softwarecodehelp.com/Trackback.aspx?guid=cc3464bc-eb52-4a0d-a5b4-c60082cc4a6a</trackback:ping>
      <pingback:server>http://blog.softwarecodehelp.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.softwarecodehelp.com/PermaLink,guid,cc3464bc-eb52-4a0d-a5b4-c60082cc4a6a.aspx</pingback:target>
      <dc:creator>Raj Shekhar</dc:creator>
      <wfw:comment>http://blog.softwarecodehelp.com/CommentView,guid,cc3464bc-eb52-4a0d-a5b4-c60082cc4a6a.aspx</wfw:comment>
      <wfw:commentRss>http://blog.softwarecodehelp.com/SyndicationService.asmx/GetEntryCommentsRss?guid=cc3464bc-eb52-4a0d-a5b4-c60082cc4a6a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Process-per-client Architecture. 
<br />
Multithreaded Architecture. 
<br />
Hybrid Architecture.
</p>
        <img width="0" height="0" src="http://blog.softwarecodehelp.com/aggbug.ashx?id=cc3464bc-eb52-4a0d-a5b4-c60082cc4a6a" />
      </body>
      <title>What are the three types of SQL database server architecture?</title>
      <guid isPermaLink="false">http://blog.softwarecodehelp.com/PermaLink,guid,cc3464bc-eb52-4a0d-a5b4-c60082cc4a6a.aspx</guid>
      <link>http://blog.softwarecodehelp.com/2009/10/20/WhatAreTheThreeTypesOfSQLDatabaseServerArchitecture.aspx</link>
      <pubDate>Tue, 20 Oct 2009 06:10:59 GMT</pubDate>
      <description>&lt;p&gt;
Process-per-client Architecture. 
&lt;br&gt;
Multithreaded Architecture. 
&lt;br&gt;
Hybrid Architecture.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.softwarecodehelp.com/aggbug.ashx?id=cc3464bc-eb52-4a0d-a5b4-c60082cc4a6a" /&gt;</description>
      <comments>http://blog.softwarecodehelp.com/CommentView,guid,cc3464bc-eb52-4a0d-a5b4-c60082cc4a6a.aspx</comments>
      <category>Interview Question SQL</category>
      <category>SQL Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.softwarecodehelp.com/Trackback.aspx?guid=e882302a-2109-4f21-8a82-3b082f817c3b</trackback:ping>
      <pingback:server>http://blog.softwarecodehelp.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.softwarecodehelp.com/PermaLink,guid,e882302a-2109-4f21-8a82-3b082f817c3b.aspx</pingback:target>
      <dc:creator>Raj Shekhar</dc:creator>
      <wfw:comment>http://blog.softwarecodehelp.com/CommentView,guid,e882302a-2109-4f21-8a82-3b082f817c3b.aspx</wfw:comment>
      <wfw:commentRss>http://blog.softwarecodehelp.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e882302a-2109-4f21-8a82-3b082f817c3b</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
For Example:
</p>
        <p>
          <span class="value">Number Value.....<br />
1          AD<br />
2          GD<br />
2          DE<br />
3          IF<br />
4          OG<br /></span>
          <span class="value">4         
JD<br /><br />
The output I would like is:-<br /><br />
1         AD<br />
2         GD,DE<br />
3         IF<br />
4         OG,JD</span>
        </p>
        <p>
You can also resolve this problem using function.
</p>
        <font color="#0000ff" size="2">
          <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
            <p>
Create
</p>
          </blockquote>
        </font>
        <font color="#000000" size="2">
        </font>
        <font color="#0000ff" size="2">Function</font>
        <font color="#000000" size="2"> Concat</font>
        <font color="#808080" size="2">( </font>
        <font size="2">@iNumber </font>
        <font color="#0000ff" size="2">int</font>
        <font size="2">
        </font>
        <font color="#808080" size="2">)</font>
        <font size="2">
          <font color="#000000">
            <br />
          </font>
        </font>
        <font color="#0000ff" size="2">RETURNS</font>
        <font color="#000000" size="2">
        </font>
        <font color="#0000ff" size="2">varchar</font>
        <font color="#808080" size="2">(</font>
        <font color="#000000" size="2">500</font>
        <font color="#808080" size="2">)<br /></font>
        <font color="#0000ff" size="2">AS<br />
BEGIN</font>
        <font size="2">
          <font color="#000000"> <br /></font>
        </font>
        <font color="#0000ff" size="2">   DECLARE</font>
        <font size="2"> @List </font>
        <font color="#0000ff" size="2">varchar</font>
        <font color="#808080" size="2">(</font>
        <font size="2">500</font>
        <font color="#808080" size="2">)<br /></font>
        <font color="#0000ff" size="2">   SET</font>
        <font size="2"> @List </font>
        <font color="#808080" size="2">=</font>
        <font size="2">
        </font>
        <font color="#ff0000" size="2">''<br /></font>
        <font color="#0000ff" size="2">   Select</font>
        <font size="2"> @List </font>
        <font color="#808080" size="2">=</font>
        <font size="2"> @List </font>
        <font color="#808080" size="2">+</font>
        <font size="2"> strValue </font>
        <font color="#808080" size="2">+</font>
        <font size="2">
        </font>
        <font color="#ff0000" size="2">','</font>
        <font size="2">
        </font>
        <font color="#0000ff" size="2">from</font>
        <font size="2"> Testing<br /></font>
        <font color="#0000ff" size="2">   Where</font>
        <font size="2"> Number </font>
        <font color="#808080" size="2">=</font>
        <font size="2"> @iNumber<br /></font>
        <font color="#0000ff" size="2">   RETURN</font>
        <font size="2">
        </font>
        <font color="#808080" size="2">LEFT(</font>
        <font size="2">@List</font>
        <font color="#808080" size="2">,</font>
        <font color="#ff00ff" size="2">LEN</font>
        <font color="#808080" size="2">(</font>
        <font size="2">@List</font>
        <font color="#808080" size="2">)-</font>
        <font size="2">1</font>
        <font color="#808080" size="2">)<br /></font>
        <font color="#0000ff" size="2">End
</font>
        <p>
And use this function in SQL Query.
</p>
        <font color="#0000ff" size="2">
          <p>
select
</p>
        </font>
        <font color="#000000" size="2"> Number</font>
        <font color="#808080" size="2">,</font>
        <font color="#000000" size="2"> dbo</font>
        <font color="#808080" size="2">.</font>
        <font color="#000000" size="2">Concat</font>
        <font color="#808080" size="2">(</font>
        <font color="#000000" size="2">Number</font>
        <font color="#808080" size="2">)</font>
        <font color="#000000" size="2">
        </font>
        <font color="#0000ff" size="2">from</font>
        <font color="#000000" size="2"> Testing </font>
        <font color="#0000ff" size="2">Group</font>
        <font color="#000000" size="2">
        </font>
        <font color="#0000ff" size="2">By</font>
        <font size="2">
          <font color="#000000"> Number</font>
        </font>
        <img width="0" height="0" src="http://blog.softwarecodehelp.com/aggbug.ashx?id=e882302a-2109-4f21-8a82-3b082f817c3b" />
      </body>
      <title>Concatenate Field Values in One String using Group By in SQL Server 2005</title>
      <guid isPermaLink="false">http://blog.softwarecodehelp.com/PermaLink,guid,e882302a-2109-4f21-8a82-3b082f817c3b.aspx</guid>
      <link>http://blog.softwarecodehelp.com/2009/09/29/ConcatenateFieldValuesInOneStringUsingGroupByInSQLServer2005.aspx</link>
      <pubDate>Tue, 29 Sep 2009 02:46:35 GMT</pubDate>
      <description>&lt;p&gt;
For Example:
&lt;/p&gt;
&lt;p&gt;
&lt;span class=value&gt;Number Value.....&lt;br&gt;
1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AD&lt;br&gt;
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GD&lt;br&gt;
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DE&lt;br&gt;
3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF&lt;br&gt;
4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OG&lt;br&gt;
&lt;/span&gt;&lt;span class=value&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JD&lt;br&gt;
&lt;br&gt;
The output I would like is:-&lt;br&gt;
&lt;br&gt;
1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AD&lt;br&gt;
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GD,DE&lt;br&gt;
3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF&lt;br&gt;
4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OG,JD&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
You can also resolve this problem using function.
&lt;/p&gt;
&lt;font color=#0000ff size=2&gt; &lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
Create
&lt;/font&gt;&lt;font color=#000000 size=2&gt; &lt;/font&gt;&lt;font color=#0000ff size=2&gt;Function&lt;/font&gt;&lt;font color=#000000 size=2&gt; Concat&lt;/font&gt;&lt;font color=#808080 size=2&gt;( &lt;/font&gt;&lt;font size=2&gt;@iNumber &lt;/font&gt;&lt;font color=#0000ff size=2&gt;int&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#808080 size=2&gt;)&lt;/font&gt;&lt;font size=2&gt;&lt;font color=#000000&gt; 
&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;RETURNS&lt;/font&gt;&lt;font color=#000000 size=2&gt; &lt;/font&gt;&lt;font color=#0000ff size=2&gt;varchar&lt;/font&gt;&lt;font color=#808080 size=2&gt;(&lt;/font&gt;&lt;font color=#000000 size=2&gt;500&lt;/font&gt;&lt;font color=#808080 size=2&gt;)&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff size=2&gt;AS&lt;br&gt;
BEGIN&lt;/font&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DECLARE&lt;/font&gt;&lt;font size=2&gt; @List &lt;/font&gt;&lt;font color=#0000ff size=2&gt;varchar&lt;/font&gt;&lt;font color=#808080 size=2&gt;(&lt;/font&gt;&lt;font size=2&gt;500&lt;/font&gt;&lt;font color=#808080 size=2&gt;)&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;SET&lt;/font&gt;&lt;font size=2&gt; @List &lt;/font&gt;&lt;font color=#808080 size=2&gt;=&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#ff0000 size=2&gt;''&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Select&lt;/font&gt;&lt;font size=2&gt; @List &lt;/font&gt;&lt;font color=#808080 size=2&gt;=&lt;/font&gt;&lt;font size=2&gt; @List &lt;/font&gt;&lt;font color=#808080 size=2&gt;+&lt;/font&gt;&lt;font size=2&gt; strValue &lt;/font&gt;&lt;font color=#808080 size=2&gt;+&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#ff0000 size=2&gt;','&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#0000ff size=2&gt;from&lt;/font&gt;&lt;font size=2&gt; Testing&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Where&lt;/font&gt;&lt;font size=2&gt; Number &lt;/font&gt;&lt;font color=#808080 size=2&gt;=&lt;/font&gt;&lt;font size=2&gt; @iNumber&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;RETURN&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#808080 size=2&gt;LEFT(&lt;/font&gt;&lt;font size=2&gt;@List&lt;/font&gt;&lt;font color=#808080 size=2&gt;,&lt;/font&gt;&lt;font color=#ff00ff size=2&gt;LEN&lt;/font&gt;&lt;font color=#808080 size=2&gt;(&lt;/font&gt;&lt;font size=2&gt;@List&lt;/font&gt;&lt;font color=#808080 size=2&gt;)-&lt;/font&gt;&lt;font size=2&gt;1&lt;/font&gt;&lt;font color=#808080 size=2&gt;)&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff size=2&gt;End&gt;
&gt;&lt;/font&gt; 
&lt;p&gt;
And use this function in SQL Query.
&lt;/p&gt;
&lt;font color=#0000ff size=2&gt; 
&lt;p&gt;
select
&lt;/font&gt;&lt;font color=#000000 size=2&gt; Number&lt;/font&gt;&lt;font color=#808080 size=2&gt;,&lt;/font&gt;&lt;font color=#000000 size=2&gt; dbo&lt;/font&gt;&lt;font color=#808080 size=2&gt;.&lt;/font&gt;&lt;font color=#000000 size=2&gt;Concat&lt;/font&gt;&lt;font color=#808080 size=2&gt;(&lt;/font&gt;&lt;font color=#000000 size=2&gt;Number&lt;/font&gt;&lt;font color=#808080 size=2&gt;)&lt;/font&gt;&lt;font color=#000000 size=2&gt; &lt;/font&gt;&lt;font color=#0000ff size=2&gt;from&lt;/font&gt;&lt;font color=#000000 size=2&gt; Testing &lt;/font&gt;&lt;font color=#0000ff size=2&gt;Group&lt;/font&gt;&lt;font color=#000000 size=2&gt; &lt;/font&gt;&lt;font color=#0000ff size=2&gt;By&lt;/font&gt;&lt;font size=2&gt;&lt;font color=#000000&gt; Number&lt;/font&gt;&gt;
&lt;/font&gt;&lt;img width="0" height="0" src="http://blog.softwarecodehelp.com/aggbug.ashx?id=e882302a-2109-4f21-8a82-3b082f817c3b" /&gt;</description>
      <comments>http://blog.softwarecodehelp.com/CommentView,guid,e882302a-2109-4f21-8a82-3b082f817c3b.aspx</comments>
      <category>SQL Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.softwarecodehelp.com/Trackback.aspx?guid=9431a22b-14d4-481f-be90-6b0654a5d332</trackback:ping>
      <pingback:server>http://blog.softwarecodehelp.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.softwarecodehelp.com/PermaLink,guid,9431a22b-14d4-481f-be90-6b0654a5d332.aspx</pingback:target>
      <dc:creator>Raj Shekhar</dc:creator>
      <wfw:comment>http://blog.softwarecodehelp.com/CommentView,guid,9431a22b-14d4-481f-be90-6b0654a5d332.aspx</wfw:comment>
      <wfw:commentRss>http://blog.softwarecodehelp.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9431a22b-14d4-481f-be90-6b0654a5d332</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <br />
          <strong>1. Use views and stored procedures instead of heavy-duty queries.<br /></strong>This can reduce network traffic, because your client will send to server
only stored procedure or view name (perhaps with some parameters) instead of large
heavy-duty queries text. This can be used to facilitate permission management also,
because you can restrict user access to table columns they should not see. 
</p>
        <p>
          <strong>2. Try to use constraints instead of triggers, whenever possible.</strong>
          <br />
Constraints are much more efficient than triggers and can boost performance. So, you
should use constraints instead of triggers, whenever possible. 
</p>
        <p>
          <strong>3. Use table variables instead of temporary tables.</strong>
          <br />
Table variables require less locking and logging resources than temporary tables,
so table variables should be used whenever possible. The table variables are available
in SQL Server 2000 only. 
</p>
        <p>
          <strong>4. Try to use UNION ALL statement instead of UNION, whenever possible.</strong>
          <br />
The UNION ALL statement is much faster than UNION, because UNION ALL statement does
not look for duplicate rows, and UNION statement does look for duplicate rows, whether
or not they exist. 
</p>
        <p>
          <strong>5. Try to avoid using the DISTINCT clause, whenever possible.</strong>
          <br />
Because using the DISTINCT clause will result in some performance degradation, you
should use this clause only when it is necessary. 
</p>
        <p>
          <strong>6. Try to avoid using SQL Server cursors, whenever possible.</strong>
          <br />
SQL Server cursors can result in some performance degradation in comparison with select
statements. Try to use correlated sub-query or derived tables, if you need to perform
row-by-row operations. 
</p>
        <p>
          <strong>7. Try to avoid the HAVING clause, whenever possible.</strong>
          <br />
The HAVING clause is used to restrict the result set returned by the GROUP BY clause.
When you use GROUP BY with the HAVING clause, the GROUP BY clause divides the rows
into sets of grouped rows and aggregates their values, and then the HAVING clause
eliminates undesired aggregated groups. In many cases, you can write your select statement
so, that it will contain only WHERE and GROUP BY clauses without HAVING clause. This
can improve the performance of your query. 
</p>
        <p>
          <strong>8. If you need to return the total table's row count, you can use alternative
way instead of SELECT COUNT(*) statement.</strong>
          <br />
Because SELECT COUNT(*) statement make a full table scan to return the total table's
row count, it can take very many time for the large table. There is another way to
determine the total row count in a table. You can use sysindexes system table, in
this case. There is ROWS column in the sysindexes table. This column contains the
total row count for each table in your database. So, you can use the following select
statement instead of SELECT COUNT(*): SELECT rows FROM sysindexes WHERE id = OBJECT_ID('table_name')
AND indid &lt; 2 So, you can improve the speed of such queries in several times. 
</p>
        <p>
          <strong>9. Include SET NOCOUNT ON statement into your stored procedures to stop the
message indicating the number of rows affected by a T-SQL statement.</strong>
          <br />
This can reduce network traffic, because your client will not receive the message
indicating the number of rows affected by a T-SQL statement. 
</p>
        <p>
          <strong>10. Try to restrict the queries result set by using the WHERE clause.</strong>
          <br />
This can results in good performance benefits, because SQL Server will return to client
only particular rows, not all rows from the table(s). This can reduce network traffic
and boost the overall performance of the query. 
</p>
        <p>
          <strong>11. Use the select statements with TOP keyword or the SET ROWCOUNT statement,
if you need to return only the first n rows.</strong>
          <br />
This can improve performance of your queries, because the smaller result set will
be returned. This can also reduce the traffic between the server and the clients. 
</p>
        <p>
          <strong>12. Try to restrict the queries result set by returning only the particular
columns from the table, not all table's columns.</strong>
          <br />
This can results in good performance benefits, because SQL Server will return to client
only particular columns, not all table's columns. This can reduce network traffic
and boost the overall performance of the query. <br />
   
<br /><strong>Index Optimization Tips. 
<br /><br /></strong>• Every index increases the time in takes to perform INSERTS, UPDATES and
DELETES, so the number of indexes should not be very much. Try to use maximum 4-5
indexes on one table, not more. If you have read-only table, then the number of indexes
may be increased. 
</p>
        <p>
• Keep your indexes as narrow as possible. This reduces the size of the index and
reduces the number of reads required to read the index. 
</p>
        <p>
• Try to create indexes on columns that have integer values rather than character
values. 
</p>
        <p>
• If you create a composite (multi-column) index, the order of the columns in the
key are very important. Try to order the columns in the key as to enhance selectivity,
with the most selective columns to the leftmost of the key. 
</p>
        <p>
• If you want to join several tables, try to create surrogate integer keys for this
purpose and create indexes on their columns. 
</p>
        <p>
• Create surrogate integer primary key (identity for example) if your table will not
have many insert operations. 
</p>
        <p>
• Clustered indexes are more preferable than nonclustered, if you need to select by
a range of values or you need to sort results set with GROUP BY or ORDER BY. 
<br />
 <br /></p>
        <img width="0" height="0" src="http://blog.softwarecodehelp.com/aggbug.ashx?id=9431a22b-14d4-481f-be90-6b0654a5d332" />
      </body>
      <title>How to Optimized your SQL. </title>
      <guid isPermaLink="false">http://blog.softwarecodehelp.com/PermaLink,guid,9431a22b-14d4-481f-be90-6b0654a5d332.aspx</guid>
      <link>http://blog.softwarecodehelp.com/2009/07/09/HowToOptimizedYourSQL.aspx</link>
      <pubDate>Thu, 09 Jul 2009 06:17:55 GMT</pubDate>
      <description>&lt;p&gt;
&lt;br&gt;
&lt;strong&gt;1. Use views and stored procedures instead of heavy-duty queries.&lt;br&gt;
&lt;/strong&gt;This can reduce network traffic, because your client will send to server
only stored procedure or view name (perhaps with some parameters) instead of large
heavy-duty queries text. This can be used to facilitate permission management also,
because you can restrict user access to table columns they should not see. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;2. Try to use constraints instead of triggers, whenever possible.&lt;/strong&gt;
&lt;br&gt;
Constraints are much more efficient than triggers and can boost performance. So, you
should use constraints instead of triggers, whenever possible. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;3. Use table variables instead of temporary tables.&lt;/strong&gt;
&lt;br&gt;
Table variables require less locking and logging resources than temporary tables,
so table variables should be used whenever possible. The table variables are available
in SQL Server 2000 only. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;4. Try to use UNION ALL statement instead of UNION, whenever possible.&lt;/strong&gt;
&lt;br&gt;
The UNION ALL statement is much faster than UNION, because UNION ALL statement does
not look for duplicate rows, and UNION statement does look for duplicate rows, whether
or not they exist. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;5. Try to avoid using the DISTINCT clause, whenever possible.&lt;/strong&gt;
&lt;br&gt;
Because using the DISTINCT clause will result in some performance degradation, you
should use this clause only when it is necessary. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;6. Try to avoid using SQL Server cursors, whenever possible.&lt;/strong&gt;
&lt;br&gt;
SQL Server cursors can result in some performance degradation in comparison with select
statements. Try to use correlated sub-query or derived tables, if you need to perform
row-by-row operations. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;7. Try to avoid the HAVING clause, whenever possible.&lt;/strong&gt;
&lt;br&gt;
The HAVING clause is used to restrict the result set returned by the GROUP BY clause.
When you use GROUP BY with the HAVING clause, the GROUP BY clause divides the rows
into sets of grouped rows and aggregates their values, and then the HAVING clause
eliminates undesired aggregated groups. In many cases, you can write your select statement
so, that it will contain only WHERE and GROUP BY clauses without HAVING clause. This
can improve the performance of your query. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;8. If you need to return the total table's row count, you can use alternative
way instead of SELECT COUNT(*) statement.&lt;/strong&gt;
&lt;br&gt;
Because SELECT COUNT(*) statement make a full table scan to return the total table's
row count, it can take very many time for the large table. There is another way to
determine the total row count in a table. You can use sysindexes system table, in
this case. There is ROWS column in the sysindexes table. This column contains the
total row count for each table in your database. So, you can use the following select
statement instead of SELECT COUNT(*): SELECT rows FROM sysindexes WHERE id = OBJECT_ID('table_name')
AND indid &amp;lt; 2 So, you can improve the speed of such queries in several times. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;9. Include SET NOCOUNT ON statement into your stored procedures to stop the
message indicating the number of rows affected by a T-SQL statement.&lt;/strong&gt;
&lt;br&gt;
This can reduce network traffic, because your client will not receive the message
indicating the number of rows affected by a T-SQL statement. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;10. Try to restrict the queries result set by using the WHERE clause.&lt;/strong&gt;
&lt;br&gt;
This can results in good performance benefits, because SQL Server will return to client
only particular rows, not all rows from the table(s). This can reduce network traffic
and boost the overall performance of the query. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;11. Use the select statements with TOP keyword or the SET ROWCOUNT statement,
if you need to return only the first n rows.&lt;/strong&gt;
&lt;br&gt;
This can improve performance of your queries, because the smaller result set will
be returned. This can also reduce the traffic between the server and the clients. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;12. Try to restrict the queries result set by returning only the particular
columns from the table, not all table's columns.&lt;/strong&gt;
&lt;br&gt;
This can results in good performance benefits, because SQL Server will return to client
only particular columns, not all table's columns. This can reduce network traffic
and boost the overall performance of the query.&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&lt;strong&gt;Index Optimization Tips. 
&lt;br&gt;
&lt;br&gt;
&lt;/strong&gt;• Every index increases the time in takes to perform INSERTS, UPDATES and
DELETES, so the number of indexes should not be very much. Try to use maximum 4-5
indexes on one table, not more. If you have read-only table, then the number of indexes
may be increased. 
&lt;/p&gt;
&lt;p&gt;
• Keep your indexes as narrow as possible. This reduces the size of the index and
reduces the number of reads required to read the index. 
&lt;/p&gt;
&lt;p&gt;
• Try to create indexes on columns that have integer values rather than character
values. 
&lt;/p&gt;
&lt;p&gt;
• If you create a composite (multi-column) index, the order of the columns in the
key are very important. Try to order the columns in the key as to enhance selectivity,
with the most selective columns to the leftmost of the key. 
&lt;/p&gt;
&lt;p&gt;
• If you want to join several tables, try to create surrogate integer keys for this
purpose and create indexes on their columns. 
&lt;/p&gt;
&lt;p&gt;
• Create surrogate integer primary key (identity for example) if your table will not
have many insert operations. 
&lt;/p&gt;
&lt;p&gt;
• Clustered indexes are more preferable than nonclustered, if you need to select by
a range of values or you need to sort results set with GROUP BY or ORDER BY. 
&lt;br&gt;
&amp;nbsp;&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.softwarecodehelp.com/aggbug.ashx?id=9431a22b-14d4-481f-be90-6b0654a5d332" /&gt;</description>
      <comments>http://blog.softwarecodehelp.com/CommentView,guid,9431a22b-14d4-481f-be90-6b0654a5d332.aspx</comments>
      <category>SQL Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.softwarecodehelp.com/Trackback.aspx?guid=f7e5a44f-b621-4b58-ab16-b16019c87f00</trackback:ping>
      <pingback:server>http://blog.softwarecodehelp.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.softwarecodehelp.com/PermaLink,guid,f7e5a44f-b621-4b58-ab16-b16019c87f00.aspx</pingback:target>
      <dc:creator>Raj Shekhar</dc:creator>
      <wfw:comment>http://blog.softwarecodehelp.com/CommentView,guid,f7e5a44f-b621-4b58-ab16-b16019c87f00.aspx</wfw:comment>
      <wfw:commentRss>http://blog.softwarecodehelp.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f7e5a44f-b621-4b58-ab16-b16019c87f00</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In SQL Server 2000,
</p>
        <p>
          <br />
sp_lock is used to find dead lock inside the database.<br />
if any dead lock occur then using "Kill spid" is to remove the dead lock.
</p>
        <img width="0" height="0" src="http://blog.softwarecodehelp.com/aggbug.ashx?id=f7e5a44f-b621-4b58-ab16-b16019c87f00" />
      </body>
      <title>How to find deadlock in SQL Server database and how to remove it.</title>
      <guid isPermaLink="false">http://blog.softwarecodehelp.com/PermaLink,guid,f7e5a44f-b621-4b58-ab16-b16019c87f00.aspx</guid>
      <link>http://blog.softwarecodehelp.com/2009/06/21/HowToFindDeadlockInSQLServerDatabaseAndHowToRemoveIt.aspx</link>
      <pubDate>Sun, 21 Jun 2009 10:39:11 GMT</pubDate>
      <description>&lt;p&gt;
In SQL Server 2000,
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
sp_lock is used to find dead lock inside the database.&lt;br&gt;
if any dead lock occur then using "Kill spid" is to remove the dead lock.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.softwarecodehelp.com/aggbug.ashx?id=f7e5a44f-b621-4b58-ab16-b16019c87f00" /&gt;</description>
      <comments>http://blog.softwarecodehelp.com/CommentView,guid,f7e5a44f-b621-4b58-ab16-b16019c87f00.aspx</comments>
      <category>SQL Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.softwarecodehelp.com/Trackback.aspx?guid=dc23d1a3-d256-4fb1-8528-da5841bf59e6</trackback:ping>
      <pingback:server>http://blog.softwarecodehelp.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.softwarecodehelp.com/PermaLink,guid,dc23d1a3-d256-4fb1-8528-da5841bf59e6.aspx</pingback:target>
      <dc:creator>Raj Shekhar</dc:creator>
      <wfw:comment>http://blog.softwarecodehelp.com/CommentView,guid,dc23d1a3-d256-4fb1-8528-da5841bf59e6.aspx</wfw:comment>
      <wfw:commentRss>http://blog.softwarecodehelp.com/SyndicationService.asmx/GetEntryCommentsRss?guid=dc23d1a3-d256-4fb1-8528-da5841bf59e6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
tempdb is one of the key working areas for your server. Whenever you issue a complex
or large query that SQL Server needs to build interim tables to solve, it does so
in tempdb. Whenever you create a temporary table of your own, it is created in tempdb,
even though you think you’re creating it in the current database. Whenever there is
a need for data to be stored temporarily, it’s probably stored in tempdb.
</p>
        <img width="0" height="0" src="http://blog.softwarecodehelp.com/aggbug.ashx?id=dc23d1a3-d256-4fb1-8528-da5841bf59e6" />
      </body>
      <title>What is the role of tempdb in SQL Server 2005</title>
      <guid isPermaLink="false">http://blog.softwarecodehelp.com/PermaLink,guid,dc23d1a3-d256-4fb1-8528-da5841bf59e6.aspx</guid>
      <link>http://blog.softwarecodehelp.com/2009/06/21/WhatIsTheRoleOfTempdbInSQLServer2005.aspx</link>
      <pubDate>Sun, 21 Jun 2009 10:14:49 GMT</pubDate>
      <description>&lt;p&gt;
tempdb is one of the key working areas for your server. Whenever you issue a complex
or large query that SQL Server needs to build interim tables to solve, it does so
in tempdb. Whenever you create a temporary table of your own, it is created in tempdb,
even though you think you’re creating it in the current database. Whenever there is
a need for data to be stored temporarily, it’s probably stored in tempdb.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.softwarecodehelp.com/aggbug.ashx?id=dc23d1a3-d256-4fb1-8528-da5841bf59e6" /&gt;</description>
      <comments>http://blog.softwarecodehelp.com/CommentView,guid,dc23d1a3-d256-4fb1-8528-da5841bf59e6.aspx</comments>
      <category>SQL Server</category>
    </item>
  </channel>
</rss>