<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8913659610460375389</id><updated>2012-02-16T11:38:11.592+03:00</updated><category term='CLR'/><category term='Sequence number'/><category term='Performance'/><category term='Download'/><category term='Technology Jokes'/><category term='Article'/><category term='INDEXES'/><category term='Question of the Day'/><category term='Performance monitoring tools'/><category term='Strings'/><category term='White papers'/><category term='Identity'/><category term='LPAD'/><category term='T-SQL best practices'/><category term='Hijri date'/><category term='User tables'/><category term='NOLOCK'/><category term='SELECT'/><category term='LDF'/><category term='system tables in SQL server'/><category term='SQL Azure'/><category term='SET'/><category term='master_files'/><category term='Duplicates'/><category term='SQL tutorials'/><category term='Cursors'/><category term='SQL Server 2008'/><category term='Certification'/><category term='Data files'/><category term='NEWID()'/><category term='NULL'/><category term='Sql Server Loading'/><category term='UDF'/><category term='SQL Server 2005'/><category term='ROW_NUMBER()'/><category term='Prometric'/><category term='XML'/><category term='SQL profiler'/><category term='COM'/><category term='Tips'/><category term='SELECT INTO'/><category term='Collation'/><category term='CTE'/><category term='SQL Server Basics'/><category term='Unused objects'/><category term='useful scripts'/><category term='Tools'/><category term='MDF'/><category term='Tips and Tricks'/><title type='text'>Think SQL...</title><subtitle type='html'>THINK SQL Blog aims in serving the community in a better way. Its purely non-monetary blog. Please post your valuable articles, share your ideas for writing better scipts in SQL Server. Lets make a new world with good thoughts and good minds. This blog serves the SQL server community all over the world.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Mohammad Shahanshah Ansari</name><uri>http://www.blogger.com/profile/06767252392003510457</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/_js--bpISygk/SXOQyD1NKWI/AAAAAAAAAH0/VPWosz_6kuk/S220/Image005.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>45</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-279849072573147120</id><published>2011-03-01T09:14:00.002+03:00</published><updated>2011-03-01T09:15:45.040+03:00</updated><title type='text'>creating an Identity column</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small; "&gt;&lt;pre&gt;&lt;code&gt;This will create an identity column in the following table.&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, Arial, Helvetica, sans-serif; white-space: normal; "&gt;&lt;pre&gt;&lt;code&gt;CREATE TABLE dbo.MyTable (    ID INT IDENTITY(1,1)    ,MyShortDesc varchar(20)     ,MyLongDesc varchar(500)    );&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-279849072573147120?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/279849072573147120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=279849072573147120' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/279849072573147120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/279849072573147120'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2011/03/creating-identity-column_01.html' title='creating an Identity column'/><author><name>kishore kumar P</name><uri>http://www.blogger.com/profile/01466691093749788948</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-1728407777278489363</id><published>2010-06-03T14:13:00.000+03:00</published><updated>2010-06-03T14:13:40.099+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='system tables in SQL server'/><category scheme='http://www.blogger.com/atom/ns#' term='master_files'/><category scheme='http://www.blogger.com/atom/ns#' term='LDF'/><category scheme='http://www.blogger.com/atom/ns#' term='Data files'/><category scheme='http://www.blogger.com/atom/ns#' term='MDF'/><title type='text'>Data file locations</title><content type='html'>Here's a query which displays the .mdf and .ldf location of all the databases in the server.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT physical_name&lt;br /&gt;FROM master.sys.master_files&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-1728407777278489363?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/1728407777278489363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=1728407777278489363' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/1728407777278489363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/1728407777278489363'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2010/06/data-file-locations.html' title='Data file locations'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-3339907230252469816</id><published>2010-04-10T15:10:00.000+03:00</published><updated>2010-04-10T15:10:53.107+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sequence number'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='ROW_NUMBER()'/><title type='text'>Sequence number within a group</title><content type='html'>&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;The following query can be used to generate the sequence numbers within a group.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;select&amp;nbsp;&lt;/blockquote&gt;&lt;blockquote&gt;&amp;nbsp;GROUP_ID&lt;/blockquote&gt;&lt;blockquote&gt;, GROUP_COUNTER= ROW_NUMBER()&lt;/blockquote&gt;&lt;blockquote&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OVER ( &amp;nbsp;PARTITION BY [GROUP_ID]&lt;/blockquote&gt;&lt;blockquote&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ORDER BY [GROUP_ID]&lt;/blockquote&gt;&lt;blockquote&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&amp;nbsp;&lt;/blockquote&gt;&lt;blockquote&gt;from GROUP_TABLE&lt;/blockquote&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;This query can generate a&amp;nbsp;output&amp;nbsp;like the following.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;b&gt;GROUP_ID &amp;nbsp; &amp;nbsp; &amp;nbsp; GROUP_COUNTER&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;-------------------------------------------&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;AAA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;AAA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;AAA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;BBB &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;BBB &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;CCC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-3339907230252469816?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/3339907230252469816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=3339907230252469816' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3339907230252469816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3339907230252469816'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2010/04/sequence-number-within-group.html' title='Sequence number within a group'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-4351259269803092374</id><published>2009-10-20T14:31:00.000+03:00</published><updated>2009-10-20T14:31:16.647+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL tutorials'/><category scheme='http://www.blogger.com/atom/ns#' term='Download'/><title type='text'>SQL Server Video tutorials</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;There are some good video tutorials available &lt;a href="http://booktraining.org/"&gt;here&lt;/a&gt;.Check it out.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-4351259269803092374?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/4351259269803092374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=4351259269803092374' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4351259269803092374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4351259269803092374'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/10/sql-server-video-tutorials.html' title='SQL Server Video tutorials'/><author><name>Thinking SQL Team</name><uri>http://www.blogger.com/profile/03693514797016716029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-3060493766133442234</id><published>2009-10-18T13:08:00.001+03:00</published><updated>2009-10-18T13:49:54.894+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Article'/><category scheme='http://www.blogger.com/atom/ns#' term='Duplicates'/><category scheme='http://www.blogger.com/atom/ns#' term='CTE'/><category scheme='http://www.blogger.com/atom/ns#' term='ROW_NUMBER()'/><title type='text'>An interesting article - Selecting Duplicate Rows in a table</title><content type='html'>&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span style="font-family:Arial, Helvetica, sans-serif;"&gt;Hi All, we are back after a pause.Here's an interesting article which talks about the different ways of selecting the duplicate rows from a table.Hope it will be useful to you.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span style="font-family:Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span style="font-family:Arial, Helvetica, sans-serif;"&gt;&lt;a href="http://weblogs.sqlteam.com/mladenp/archive/2009/10/15/SQL-Server---How-to-get-the-whole-group-of.aspx"&gt;Article&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-3060493766133442234?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/3060493766133442234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=3060493766133442234' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3060493766133442234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3060493766133442234'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/10/interesting-article-selecting-duplicate.html' title='An interesting article - Selecting Duplicate Rows in a table'/><author><name>Thinking SQL Team</name><uri>http://www.blogger.com/profile/03693514797016716029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-8140299247150775204</id><published>2009-09-25T11:37:00.000+03:00</published><updated>2009-09-25T11:39:46.067+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='COM'/><category scheme='http://www.blogger.com/atom/ns#' term='Question of the Day'/><title type='text'>Question of the day</title><content type='html'>Can you instantiate a COM object by using T-SQL?&lt;br /&gt;&lt;br /&gt;1. True&lt;br /&gt;2. False&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-8140299247150775204?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/8140299247150775204/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=8140299247150775204' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/8140299247150775204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/8140299247150775204'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/question-of-day_25.html' title='Question of the day'/><author><name>Mohammad Shahanshah Ansari</name><uri>http://www.blogger.com/profile/06767252392003510457</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/_js--bpISygk/SXOQyD1NKWI/AAAAAAAAAH0/VPWosz_6kuk/S220/Image005.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-7452091280877023822</id><published>2009-09-23T23:59:00.000+03:00</published><updated>2009-09-23T23:59:31.605+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='T-SQL best practices'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>T-SQL best practices - 4</title><content type='html'>&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;- The dynamic SQL Performs slower because the optimizer has to create an execution plan for every execution.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;-Use table aliasing, even if there is no joining in the query. Aliasing eliminates ambiguity, eases subsequent modification, and further reduces the chance of a typo not being recognized.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;-When querying a table, prefix it with the owner (schema), typically dbo. There is a little performance improvement and query becomes more readable&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-7452091280877023822?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/7452091280877023822/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=7452091280877023822' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/7452091280877023822'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/7452091280877023822'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/t-sql-best-practices-4.html' title='T-SQL best practices - 4'/><author><name>Thinking SQL Team</name><uri>http://www.blogger.com/profile/03693514797016716029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-8076842584760647977</id><published>2009-09-23T07:27:00.003+03:00</published><updated>2009-09-23T07:33:27.192+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Question of the Day'/><category scheme='http://www.blogger.com/atom/ns#' term='Cursors'/><title type='text'>Question of the Day</title><content type='html'>&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;What are the disadvantages of cursors?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. Cursor results in a network roundtrip&lt;br /&gt;2. Cursor requires more resources and temporary storage&lt;br /&gt;3. Cursor results in more IO operations&lt;br /&gt;4. 1 &amp;amp; 2&lt;br /&gt;5. 1, 2 &amp;amp; 3&lt;br /&gt;6. None&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-8076842584760647977?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/8076842584760647977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=8076842584760647977' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/8076842584760647977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/8076842584760647977'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/question-of-day_23.html' title='Question of the Day'/><author><name>Thinking SQL Team</name><uri>http://www.blogger.com/profile/03693514797016716029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-4107237955856271784</id><published>2009-09-22T22:02:00.000+03:00</published><updated>2009-09-22T22:02:25.856+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='White papers'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Certification'/><category scheme='http://www.blogger.com/atom/ns#' term='T-SQL best practices'/><title type='text'>T-SQL best practices - 3</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Today's tips are not really&amp;nbsp;related&amp;nbsp;to T-SQL,but I hope these will improve the way you approach SQL SERVER.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="direction: ltr; language: en-US; line-height: 90%; margin-bottom: 0pt; margin-left: .38in; margin-top: 5.76pt; text-align: left; text-indent: -.38in; unicode-bidi: embed; vertical-align: baseline;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;-&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Get Certified&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="direction: ltr; language: en-US; line-height: 90%; margin-bottom: 0pt; margin-left: .38in; margin-top: 5.76pt; text-align: left; text-indent: -.38in; unicode-bidi: embed; vertical-align: baseline;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;-&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Subscribe to News Groups and blogs to get regular updates&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="direction: ltr; language: en-US; line-height: 90%; margin-bottom: 0pt; margin-left: .38in; margin-top: 5.76pt; text-align: left; text-indent: -.38in; unicode-bidi: embed; vertical-align: baseline;"&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;- Read White papers&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-4107237955856271784?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/4107237955856271784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=4107237955856271784' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4107237955856271784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4107237955856271784'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/t-sql-best-practices-3.html' title='T-SQL best practices - 3'/><author><name>Thinking SQL Team</name><uri>http://www.blogger.com/profile/03693514797016716029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-4213520363199386655</id><published>2009-09-21T21:38:00.002+03:00</published><updated>2009-09-21T21:48:48.459+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NOLOCK'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='T-SQL best practices'/><title type='text'>T-SQL best practices - 2</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;Today's best practice techniques are &lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="language:en-US;line-height:90%;margin-top:5.76pt;margin-bottom: 0pt;margin-left:.38in;text-indent:-.38in;text-align:left;direction:ltr; unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;- &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;NOLOCK helps in concurrency and performance but can be dangerous for data integrity&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div class="O1" style="language:en-US;line-height:90%;margin-top:3.84pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:justify; text-justify:inter-ideograph;direction:ltr;unicode-bidi:embed;vertical-align: baseline"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style="language:en-US;line-height:90%;margin-top:5.76pt;margin-bottom: 0pt;margin-left:.38in;text-indent:-.38in;text-align:left;direction:ltr; unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;- &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;Use XML &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;datatype&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt; to pass table valued parameters to procedures.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="O1" style="text-indent: -36px;line-height: 90%; margin-top: 3.84pt; margin-bottom: 0pt; margin-left: 0.81in; text-align: left; direction: ltr; unicode-bidi: embed; vertical-align: baseline; "&gt;&lt;span class="Apple-style-span" style="font-size: small; "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style="language:en-US;line-height:90%;margin-top:5.76pt;margin-bottom: 0pt;margin-left:.38in;text-indent:-.38in;text-align:left;direction:ltr; unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;- &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;Use SQL Server Management Console with integrated Source Control to do the development&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="language:en-US;line-height:90%;margin-top:5.76pt;margin-bottom: 0pt;margin-left:.38in;text-indent:-.38in;text-align:left;direction:ltr; unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;div class="O1" style="language:en-US;line-height:90%;margin-top:3.84pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:left; direction:ltr;unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-size:6;"&gt;&lt;span class="Apple-style-span" style="font-size: 21px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div class="O1" style="line-height: 90%; margin-top: 3.84pt; margin-bottom: 0pt; margin-left: 0.81in; text-align: left; direction: ltr; unicode-bidi: embed; vertical-align: baseline; text-indent: -0.31in; "&gt;&lt;span class="Apple-style-span" style="font-size: small; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-4213520363199386655?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/4213520363199386655/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=4213520363199386655' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4213520363199386655'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4213520363199386655'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/t-sql-best-practices-2.html' title='T-SQL best practices - 2'/><author><name>Thinking SQL Team</name><uri>http://www.blogger.com/profile/03693514797016716029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-2202405207817190774</id><published>2009-09-20T15:45:00.005+03:00</published><updated>2009-09-20T16:16:18.147+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Cursors'/><category scheme='http://www.blogger.com/atom/ns#' term='T-SQL best practices'/><title type='text'>T-SQL best practices - 1</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Hi All!...we decided to write some posts on the best practices in writing T-SQL,which we think helpful to the newbies.We will list three best practices each day for the next seven days and hope this series will be helpful to all the readers.So today's best practices tips are,&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="language:en-US;line-height:90%;margin-top:5.76pt;margin-bottom: 0pt;margin-left:.38in;text-indent:-.38in;text-align:left;direction:ltr; unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;b&gt;Document your database&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div class="O1" style="language:en-US;line-height:90%;margin-top:4.8pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:left; direction:ltr;unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;–&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Use Extended properties of the table structures to document the database.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div class="O1" style="language:en-US;line-height:90%;margin-top:4.8pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:left; direction:ltr;unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;–&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Use tools to generate the documentation and correct where necessary&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div class="O1" style="language:en-US;line-height:90%;margin-top:4.8pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:left; direction:ltr;unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;–&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Maintain the script for populating the extended properties.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style="language:en-US;line-height:90%;margin-top:5.76pt;margin-bottom: 0pt;margin-left:.38in;text-indent:-.38in;text-align:left;direction:ltr; unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;b&gt;Use Cursors only when&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div class="O1" style="language:en-US;line-height:90%;margin-top:4.8pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:left; direction:ltr;unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;–&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;You cannot find a set based solution in 4 Hours&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div class="O1" style="language:en-US;line-height:90%;margin-top:4.8pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:left; direction:ltr;unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;–&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;You want to utilize already existing logic in other SP&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div class="O1" style="language:en-US;line-height:90%;margin-top:4.8pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:left; direction:ltr;unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;–&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;You are writing a database maintenance task&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style="language:en-US;line-height:90%;margin-top:5.76pt;margin-bottom: 0pt;margin-left:.38in;text-indent:-.38in;text-align:left;direction:ltr; unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;b&gt;Use STATISTICS IO ON&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div class="O1" style="language:en-US;line-height:90%;margin-top:4.8pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:left; direction:ltr;unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;–This will r&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;educe the logical reads&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="O1" style="language:en-US;line-height:90%;margin-top:4.8pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:left; direction:ltr;unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="O1" style="language:en-US;line-height:90%;margin-top:4.8pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:left; direction:ltr;unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;We need your comments on this post and share the best practices that you are using in the script(related to the above 3 techniques)&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="O1" style="language:en-US;line-height:90%;margin-top:4.8pt; margin-bottom:0pt;margin-left:.81in;text-indent:-.31in;text-align:left; direction:ltr;unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-2202405207817190774?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/2202405207817190774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=2202405207817190774' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/2202405207817190774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/2202405207817190774'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/t-sql-best-practices-1.html' title='T-SQL best practices - 1'/><author><name>Thinking SQL Team</name><uri>http://www.blogger.com/profile/03693514797016716029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-8500206172947383745</id><published>2009-09-19T14:30:00.002+03:00</published><updated>2009-09-19T14:35:21.098+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LPAD'/><category scheme='http://www.blogger.com/atom/ns#' term='UDF'/><category scheme='http://www.blogger.com/atom/ns#' term='Strings'/><title type='text'>Left Padding(LPAD) using REPLICATE</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Here's a SQL UDF to do the left padding using REPLICATE.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;create function [dbo].[leftpad] &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@csrting nvarchar(4000)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, @nlen smallint&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, @cpadcharacter nvarchar(4000) = ' ' &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;returns nvarchar(4000)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;begin&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;         declare @nleftlen smallint,  @nrightlen smallint&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;         declare @length smallint, @lenpadcharacter smallint&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        select  @length = datalength(@csrting)/(case sql_variant_property(@csrting,'basetype') when 'nvarchar' then 2  else 1 end) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        select  @lenpadcharacter = datalength(@cpadcharacter)/(case sql_variant_property(@cpadcharacter,'basetype') when 'nvarchar' then 2  else 1 end) -- for unicode&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        if @length &gt;= @nlen&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;           set  @csrting = left(@csrting, @nlen)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   begin&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;              set @nleftlen = @nlen - @length &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;              set @csrting = left(replicate(@cpadcharacter, ceiling(@nleftlen/@lenpadcharacter) + 2), @nleftlen)+ @csrting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;           end&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    return (@csrting)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-8500206172947383745?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/8500206172947383745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=8500206172947383745' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/8500206172947383745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/8500206172947383745'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/left-paddinglpad-using-replicate.html' title='Left Padding(LPAD) using REPLICATE'/><author><name>Thinking SQL Team</name><uri>http://www.blogger.com/profile/03693514797016716029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-3878471185343361322</id><published>2009-09-12T15:00:00.001+03:00</published><updated>2009-09-12T15:59:39.855+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Hijri date'/><title type='text'>Working with Hijri Date in SQL server</title><content type='html'>&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Here's an example to convert the&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; white-space: pre;"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Hijri"&gt;Hijri Date&lt;/a&gt;&lt;span id="goog_1252760268833"&gt;&lt;/span&gt;&lt;span id="goog_1252760268829"&gt;&lt;/span&gt; to Gregorian date in SQL Server&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: small;"&gt;1430/09/23 is today's&amp;nbsp;&lt;span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; white-space: pre;"&gt;Hijri &lt;/span&gt;date.Lets see how to convert this into Gregorian date&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;SELECT CONVERT(DATETIME, '23/09/1430', 131)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: small;"&gt;It would return 2009-09-12 00:00:00.000&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;The vice-versa,conversion from Gregorian date to&amp;nbsp;&lt;span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; white-space: pre;"&gt;Hijri &lt;/span&gt;date would be,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;SELECT CONVERT(NCHAR, GETDATE(), 131)&lt;/span&gt;.And this returns&amp;nbsp;23/09/1430 &amp;nbsp;2:52:17:920PM&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-3878471185343361322?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/3878471185343361322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=3878471185343361322' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3878471185343361322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3878471185343361322'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/working-with-hijri-date-in-sql-server.html' title='Working with Hijri Date in SQL server'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-8828104795574078813</id><published>2009-09-12T04:00:00.001+03:00</published><updated>2009-09-12T04:00:00.291+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL profiler'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance monitoring tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Top 10 SQL server Performance tuning tips - 10</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;Use of performance monitoring tools:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SQL server ships with many tools like Profiler,&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Database Engine Tuning Advisor,Index Tuning Wizard,PerfMon,SysMon.Make use of these tools to moniter the performance of your query and take the nessesary actions,if required.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:arial;font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;          Well,  with this post we come to an end of our series of Performance Tuning Steps.I hope its helpful to you to you and we will discuss each steps in detail in coming days.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:arial;font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-8828104795574078813?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/8828104795574078813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=8828104795574078813' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/8828104795574078813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/8828104795574078813'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/top-10-sql-server-performance-tuning_12.html' title='Top 10 SQL server Performance tuning tips - 10'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-1222918859797369562</id><published>2009-09-11T04:00:00.000+03:00</published><updated>2009-09-11T04:00:00.925+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SELECT'/><category scheme='http://www.blogger.com/atom/ns#' term='NOLOCK'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Top 10 SQL server Performance tuning tips - 9</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;&lt;b&gt;Use&lt;/b&gt;&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;&lt;b&gt;of&lt;/b&gt;&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;&lt;b&gt;NOLOCK&lt;/b&gt;&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;&lt;b&gt;hint&lt;/b&gt;&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;NOLOCK&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;hint&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;is&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;useful&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;to&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;improve&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;the&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;query&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;performance&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;when&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;selecting&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;the&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;rowset&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;from&lt;/span&gt; a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;table&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;which&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;is&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;being&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;accessed&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;by&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;multiple&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;transaction&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;But&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;this&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_28"&gt;leads&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;to&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;dirty&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;read&lt;/span&gt;.A &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;dirty&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_33"&gt;read&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_34"&gt;is&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_35"&gt;where&lt;/span&gt; a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_36"&gt;query&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_37"&gt;reads&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_38"&gt;data&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_39"&gt;from&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_40"&gt;the&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_41"&gt;database&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_42"&gt;without&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_43"&gt;lock&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_44"&gt;protection&lt;/span&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_45"&gt;Without&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_46"&gt;lock&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_47"&gt;protection&lt;/span&gt;, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_48"&gt;you&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_49"&gt;cannot&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_50"&gt;be&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_51"&gt;guaranteed&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_52"&gt;that&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_53"&gt;the&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_54"&gt;data&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_55"&gt;isn&lt;/span&gt;’t &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_56"&gt;changing&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_57"&gt;during&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_58"&gt;the&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_59"&gt;time&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_60"&gt;that&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_61"&gt;the&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_62"&gt;query&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_63"&gt;is&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_64"&gt;running&lt;/span&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-1222918859797369562?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/1222918859797369562/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=1222918859797369562' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/1222918859797369562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/1222918859797369562'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/top-10-sql-server-performance-tuning_11.html' title='Top 10 SQL server Performance tuning tips - 9'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-5222682088112666187</id><published>2009-09-10T04:00:00.001+03:00</published><updated>2009-09-10T09:47:50.280+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='NULL'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Top 10 SQL server Performance tuning tips - 8</title><content type='html'>&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51); line-height: 19px;font-family:Verdana;font-size:13;"  &gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;Reduce the NULLs&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;Reduce the use of NULLs in the database. The use of NULLs in a database can greatly reduce database performance, especially in WHERE clauses.Highly normalized database can achieve this.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-5222682088112666187?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/5222682088112666187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=5222682088112666187' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/5222682088112666187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/5222682088112666187'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/top-10-sql-server-performance-tuning_10.html' title='Top 10 SQL server Performance tuning tips - 8'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-6065231033467286783</id><published>2009-09-09T04:00:00.000+03:00</published><updated>2009-09-09T04:00:01.758+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SELECT'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='INDEXES'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Top 10 SQL server Performance tuning tips - 7</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Verdana; color: rgb(51, 51, 51); font-size: 13px; line-height: 19px; "&gt;&lt;div&gt;&lt;b&gt;Remove unwanted columns from the SELECT statement&lt;/b&gt;&lt;/div&gt;                          In queries, &lt;i&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;don't return column data you don't need&lt;/span&gt;.&lt;/b&gt;&lt;/i&gt; For example, you should not use SELECT * to return all the columns from a table if you don't need all the data from each column. In addition, using SELECT * may prevent the use of covered indexes, further potentially affect query performance.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-6065231033467286783?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/6065231033467286783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=6065231033467286783' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/6065231033467286783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/6065231033467286783'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/top-10-sql-server-performance-tuning_09.html' title='Top 10 SQL server Performance tuning tips - 7'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-2741927337486407837</id><published>2009-09-08T22:58:00.000+03:00</published><updated>2009-09-08T22:58:54.796+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips and Tricks'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Finding long running queries in SQL server</title><content type='html'>&lt;span class="Apple-style-span" style="line-height: 19px; "&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;Here's a query to find the longest running queries.This works in SQL Server 2005 and 2008.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;SELECT DISTINCT TOP &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;10&lt;br /&gt;t.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;TEXT &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;QueryName&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;s.execution_count &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;AS &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;ExecutionCount&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;s.max_elapsed_time &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;AS &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;MaxElapsedTime&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;ISNULL&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;s.total_elapsed_time &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;/ &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;s.execution_count&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;AS &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;AvgElapsedTime&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;s.creation_time &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;AS &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;LogCreatedOn&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;ISNULL&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;s.execution_count &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;/ &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;DATEDIFF&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;s.creation_time&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;GETDATE&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;()), &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;AS &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;FrequencyPerSec&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;FROM &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;sys.dm_exec_query_stats s&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;CROSS &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;APPLY sys.dm_exec_sql_text&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;( &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;s.sql_handle &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;t&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;ORDER BY&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;s.max_elapsed_time &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;DESC&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-2741927337486407837?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/2741927337486407837/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=2741927337486407837' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/2741927337486407837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/2741927337486407837'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/finding-long-running-queries-in-sql.html' title='Finding long running queries in SQL server'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-2231968647272225561</id><published>2009-09-08T04:00:00.002+03:00</published><updated>2009-09-10T17:35:52.439+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Cursors'/><category scheme='http://www.blogger.com/atom/ns#' term='CTE'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Top 10 SQL server Performance tuning tips - 6</title><content type='html'>&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Set Based Approach&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Even though procedural approach is easier for most of the programmers,&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 16px; "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;it (Use of Cursor, or, UDF to process rows in a result set) should be avoided when working with large result set.Most of the times cursors can be replaced by CTE(Common Table Expression).&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="  line-height: normal; "&gt;&lt;a href="http://blogs.techrepublic.com.com/datacenter/?p=412"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Avoiding Cursors with SQL Server 2005&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-2231968647272225561?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/2231968647272225561/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=2231968647272225561' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/2231968647272225561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/2231968647272225561'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/top-10-sql-server-performance-tuning_08.html' title='Top 10 SQL server Performance tuning tips - 6'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-4054600917619629307</id><published>2009-09-07T04:00:00.004+03:00</published><updated>2009-09-07T20:42:37.429+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Cursors'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Top 10 SQL server Performance tuning tips - 5</title><content type='html'>&lt;span style="font-weight:bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Avoid cursors&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;br /&gt;            Avoid using cursors.It may result in Deadlocks.Deadlocking occurs when two user processes have locks on separate objects and each process is trying to acquire a lock on the object that the other process has. During this kind of situation, SQL Server identifies the trouble and ends the deadlock by automatically choosing one process and aborting the other process, allowing the other process to continue.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-4054600917619629307?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/4054600917619629307/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=4054600917619629307' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4054600917619629307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4054600917619629307'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/top-10-sql-server-performance-tuning_07.html' title='Top 10 SQL server Performance tuning tips - 5'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-4690710472196562537</id><published>2009-09-06T05:00:00.000+03:00</published><updated>2009-09-06T05:00:00.257+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='INDEXES'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Top 10 SQL server Performance tuning tips - 4</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;b&gt;Use of Indexes&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;NON CLUSTERED index should be created on a highly selective field.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Order of the fields in the WHERE clause should be same as the index order.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Every table in the DB should have a CLUSTERED index.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Primary Key may not be suitable for clustered index if the table is extensively used for SELECT.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;div&gt;&lt;div style="language:en-US;line-height:90%;margin-top:4.32pt;margin-bottom: 0pt;margin-left:.5in;text-indent:-.5in;text-align:left;direction:ltr; unicode-bidi:embed;vertical-align:baseline"&gt;&lt;span class="Apple-style-span"   style="font-family:Arial;font-size:6;"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:24px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-4690710472196562537?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/4690710472196562537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=4690710472196562537' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4690710472196562537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4690710472196562537'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/top-10-sql-server-performance-tuning_06.html' title='Top 10 SQL server Performance tuning tips - 4'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-1558731917772715186</id><published>2009-09-05T00:34:00.000+03:00</published><updated>2009-09-04T22:00:14.283+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Top 10 SQL server Performance tuning tips - 3</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(51, 51, 51);   line-height: 15px; font-family:Verdana;font-size:12px;"&gt;&lt;h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0em; padding-bottom: 5px; padding-left: 0em; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;Use of OPTIMIZE FOR&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0em; padding-bottom: 5px; padding-left: 0em; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;OPTIMIZE FOR a little known but powerful SQL Server feature.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;DECLARE @ProdCode  NVARCHAR(20)&lt;br /&gt;SET @ProdCode = N’100’&lt;br /&gt;SELECT ProdId,MfnDate&lt;br /&gt;FROM Product&lt;br /&gt;WHERE ProdCode = @ProdCode&lt;br /&gt;OPTION (OPTIMIZE FOR (@ ProdCode  = N’100’))&lt;br /&gt;&lt;br /&gt;The OPTIMIZE FOR hint will force an index seek when the specific value is provided.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:arial;font-size:100%;"&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;More about &lt;span class="Apple-style-span" style="white-space: pre-wrap; "&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;OPTIMIZE FOR/OPTIMIZE FOR UNKNOWN &lt;a href="http://msdn.microsoft.com/en-us/library/ms181714.aspx"&gt;here&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-1558731917772715186?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/1558731917772715186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=1558731917772715186' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/1558731917772715186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/1558731917772715186'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/top-10-sql-server-performance-tuning_2048.html' title='Top 10 SQL server Performance tuning tips - 3'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-499899812906091022</id><published>2009-09-04T23:11:00.003+03:00</published><updated>2009-09-06T00:09:35.044+03:00</updated><title type='text'>A Milestone : 2000 visits crossed today</title><content type='html'>&lt;div style="text-align: justify; color: rgb(0, 0, 102);"&gt;It's time to cheer and rejoice as our SQL server Blog completes a milestone of 2000 visitors, from all over the world. The blog has 12 subscribers and 10 followers to its credit, if we are to count numbers, or otherwise has a huge base of loyal supporters and visitors greeting every day. In a very short duration, the blog seems to achieve a great milestone, while people still keep visiting and adding to the increasing quantitative and qualitative aspect of it.&lt;br /&gt;&lt;br /&gt;At this achievement, let’s not stop just at celebrations; instead let’s put our hands together in making this blog more readable, accessible and popular, just up to the mark of SQL Server Professionals. One small way we can help is by contributing anything possible and relevant at individual level and the blog shall, by itself march to become successful for the professionals.&lt;br /&gt;&lt;br /&gt;We appreciate the efforts of all those who are contributing to this blog in any way, big or small, post or comment. The easiest way to show liking for the blog is by making a comment, whenever an article interests one. Comment is not mere an opinion rather reflects one’s involvement for the cause. So let’s&lt;br /&gt;&lt;br /&gt;initiate the changes and put our efforts to make this blog more popular and the best among the lot for the sake of community service.&lt;br /&gt;&lt;br /&gt;I once again congratulate the whole team for this successful journey.&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Mohammad Shahanshah Ansari&lt;br /&gt;SQL Server Professional&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-499899812906091022?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/499899812906091022/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=499899812906091022' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/499899812906091022'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/499899812906091022'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/milestone-2000-visits-crossed-today.html' title='A Milestone : 2000 visits crossed today'/><author><name>Mohammad Shahanshah Ansari</name><uri>http://www.blogger.com/profile/06767252392003510457</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/_js--bpISygk/SXOQyD1NKWI/AAAAAAAAAH0/VPWosz_6kuk/S220/Image005.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-5499241314923129153</id><published>2009-09-04T10:34:00.000+03:00</published><updated>2009-09-04T10:38:36.971+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Top 10 SQL server Performance tuning tips - 2</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;div&gt;Today's performance tuning tip.&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Use of UNION/UNION ALL&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;UNI&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ON move the results to the tempdb, sort it, identify unique entries and retrieve the results.&lt;br /&gt;&lt;br /&gt;UNION ALL will not do the sort, and will not identify unique entries. The results will not be unique. This can be used when the results from two queries are distinctly different&lt;br /&gt;&lt;br /&gt;UNION will have adverse impact on the number of Reads and Writes and hence the performance.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-5499241314923129153?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/5499241314923129153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=5499241314923129153' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/5499241314923129153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/5499241314923129153'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/top-10-sql-server-performance-tuning_04.html' title='Top 10 SQL server Performance tuning tips - 2'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-3128097074033622747</id><published>2009-09-03T14:18:00.000+03:00</published><updated>2009-09-03T14:25:34.980+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL profiler'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><title type='text'>Top 10 SQL server Performance tuning tips</title><content type='html'>I planned to post some performance tuning steps ,mostly DB design related, for the next 10 days.One each day so that the readers wont get bored.So...Here we go..&lt;br /&gt;&lt;br /&gt;Use SQL Profiler&lt;br /&gt;&lt;br /&gt;  Use SQL Profiler check the Duration, Reads and Writes for each Stored Procedure and for each statement within the stored procedure.Typically Reads should not exceed four times the number of rows returned. If reads are abnormally high then indexes may require a re-look or the query has to be split depending on the complexity.Set the duration filter before running the trace to identify the queries that exceed a specific duration.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-3128097074033622747?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/3128097074033622747/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=3128097074033622747' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3128097074033622747'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3128097074033622747'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/09/top-10-sql-server-performance-tuning.html' title='Top 10 SQL server Performance tuning tips'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-2514294270178759696</id><published>2009-08-31T14:50:00.000+03:00</published><updated>2009-08-31T15:24:30.594+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Azure'/><title type='text'>SQL Azure</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;What is SQL Azure?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Microsoft® SQL Azure delivers on the Microsoft Data Platform vision of extending the SQL Server capabilities to the cloud as web-based services, enabling you to store structured, semi-structured, and unstructured data. SQL Azure will deliver a rich set of integrated services that enable you to perform relational queries, search, reporting, analytics, integration and synchronize data with mobile users, remote offices and business partners. Currently, SQL Azure offers relational database service called Microsoft® SQL Azure Database.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Here's an interesting article on SQL Azure.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;a href="http://dotnetslackers.com/articles/sql/Introduction-to-SQL-Azure.aspx"&gt;Introduction to SQL Azure&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/azure/dd439432.aspx"&gt;Azure Video tutorials&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-2514294270178759696?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/2514294270178759696/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=2514294270178759696' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/2514294270178759696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/2514294270178759696'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/08/sql-azure.html' title='SQL Azure'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-4286782450124574241</id><published>2009-08-31T14:26:00.000+03:00</published><updated>2009-08-31T14:29:18.949+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='useful scripts'/><category scheme='http://www.blogger.com/atom/ns#' term='CTE'/><title type='text'>Removing Duplicates using CTE</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Here's a code snippet which removes the duplicate records,using CTE&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;WITH CTE ([col1], cnt)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SELECT [col1],&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ROW_NUMBER() OVER(PARTITION BY [col1] ORDER BY [col1]) AS cnt&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;FROM table1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;DELETE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;FROM CTE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;WHERE cnt &gt; 1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-4286782450124574241?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/4286782450124574241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=4286782450124574241' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4286782450124574241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/4286782450124574241'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/08/removing-duplicates-using-cte.html' title='Removing Duplicates using CTE'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-8982996351187270777</id><published>2009-06-22T23:11:00.000+03:00</published><updated>2009-06-22T23:21:37.765+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Download'/><title type='text'>SQL Server 2008 Developer Training Kit</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SQL server 2008 Developer Training Kit which is released recently is available &lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=765433f7-0983-4d7a-b628-0a98145bcb97"&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:arial;font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Verdana; font-size: 11px; "&gt;&lt;b&gt;&lt;u&gt;Contents&lt;/u&gt; &lt;/b&gt;&lt;br /&gt;The training kit includes the following content:&lt;ul style="margin-bottom: 0.3em; margin-top: 0.3em; "&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Presentations (6)&lt;/li&gt;&lt;ul style="margin-bottom: 0.3em; margin-top: 0.3em; "&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Filestream&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Spatial&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;T-SQL&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Date and Time Types&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;SQLCLR&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Reporting Services&lt;/li&gt;&lt;/ul&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Demos (12)&lt;/li&gt;&lt;ul style="margin-bottom: 0.3em; margin-top: 0.3em; "&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;AdventureWorks Racing All-Up SQL Server 2008 Demo&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;SQL Server 2008 All-Up Spatial Demo&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Spatial Types Demo&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Intro to Filestream Demo&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;SQL CLR Nullable Types Demo&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Programming with Filestream Demo&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Reporting Services Web Application Integration Demo&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Date and Time Support in SQL Server 2008 Demo&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;T-SQL Table-Valued Parameters Demo&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;T-SQL Row Constructors Demo&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;T-SQL Grouping Sets Demo&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;T-SQL Merge Demo&lt;/li&gt;&lt;/ul&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Hands-on Labs (3)&lt;/li&gt;&lt;ul style="margin-bottom: 0.3em; margin-top: 0.3em; "&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Using Spatial Data in TSQL&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Using Spatial Data in Managed Code&lt;/li&gt;&lt;li style="padding-bottom: 3px; padding-top: 3px; "&gt;Using SQL CLR in SQL Server 2008 &lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div&gt;-----------------------------------------------------------------------------------------------------------------------Reference : &lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px; "&gt;&lt;b style="text-decoration: inherit; "&gt;download&lt;/b&gt;.&lt;b style="text-decoration: inherit; "&gt;microsoft&lt;/b&gt;.com&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-8982996351187270777?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/8982996351187270777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=8982996351187270777' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/8982996351187270777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/8982996351187270777'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/06/sql-server-2008-developer-training-kit.html' title='SQL Server 2008 Developer Training Kit'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-979302294389734709</id><published>2009-06-19T00:36:00.000+03:00</published><updated>2009-06-19T01:08:08.200+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Identity'/><title type='text'>Inserting values into an identity column</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The identity column gets value assigned automatically when a new records inserted into the table.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Its possible to insert a value into an identity column by setting the &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;IDENTITY_INSERT to ON.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Lets look at the following example,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:arial;font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;--Test table with an identity column&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:arial;font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;CREATE TABLE #IDENTESTTABLE &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;ROWNO_COL INT IDENTITY(1,1),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;VALUE_COL VARCHAR(15)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;--Inserting a row into the table&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; INSERT #IDENTESTTABLE(ROWNO_COL, VALUE_COL) VALUES (1, 'TEST VALUE')&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The above insert statement would terminate with the following error,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:-webkit-monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Msg 544, Level 16, State 1, Line 1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Cannot insert explicit value for identity column in table '#IdenTestTable____000000000004' &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;when IDENTITY_INSERT is set to OFF.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;To avoid this error set &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;IDENTITY_INSERT to ON.Here we go,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SET IDENTITY_INSERT #IDENTESTTABLE ON&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:arial;font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;INSERT #IDENTESTTABLE(ROWNO_COL, VALUE_COL) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;VALUES (1, 'FIRST ROW')&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:arial;font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SET IDENTITY_INSERT #IDENTESTTABLE OFF.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:arial;font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;More fun with IDENTITY &lt;a href="http://technet.microsoft.com/en-us/library/ms176057.aspx"&gt;here&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:-webkit-monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:-webkit-monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-979302294389734709?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/979302294389734709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=979302294389734709' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/979302294389734709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/979302294389734709'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/06/inserting-values-into-identity-column.html' title='Inserting values into an identity column'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-6634056925869441045</id><published>2009-06-04T14:41:00.001+03:00</published><updated>2009-06-05T01:06:02.249+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Download'/><title type='text'>SQL Server 2008 Wallpaper</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Here's a high resolution SQL Server 2008 &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;wallpaper!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_aSKO3brgpno/SihE_81jSFI/AAAAAAAAAPk/wJrdByWT6ys/s1600-h/SQL+Server+2008+wallpaper_ThinkSQL.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 320px;" src="http://1.bp.blogspot.com/_aSKO3brgpno/SihE_81jSFI/AAAAAAAAAPk/wJrdByWT6ys/s400/SQL+Server+2008+wallpaper_ThinkSQL.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5343596823328278610" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-6634056925869441045?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/6634056925869441045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=6634056925869441045' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/6634056925869441045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/6634056925869441045'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/06/sql-server-2008-wallpaper.html' title='SQL Server 2008 Wallpaper'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_aSKO3brgpno/SihE_81jSFI/AAAAAAAAAPk/wJrdByWT6ys/s72-c/SQL+Server+2008+wallpaper_ThinkSQL.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-3378366533175930869</id><published>2009-06-02T11:31:00.000+03:00</published><updated>2009-06-02T17:48:31.853+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>Error handling in UDF - I</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                 There's no straight forward way for exception handling in a UDFand programmers often let the caller code to handle the error in such cases.You can still write exception handling blocks in the &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms131045.aspx"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;CLR(&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style=" line-height: 15px; font-family:Verdana;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms131045.aspx"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The common language runtime)&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;UDFs in SQL server 2005/later.Apart from the giving better performance than T-SQL ,the CLR,allows the programmer to perform funtionality which are not available in T-SQL.Will see how to implement this in the upcoming posts!&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-3378366533175930869?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/3378366533175930869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=3378366533175930869' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3378366533175930869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3378366533175930869'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/06/error-handling-in-udf-i.html' title='Error handling in UDF - I'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-124456506681368722</id><published>2009-06-02T00:31:00.000+03:00</published><updated>2009-06-02T00:47:52.270+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technology Jokes'/><title type='text'>Funny SQL Query!</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;div&gt;Just found this funny PL/SQL wedding query.Check it out.  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;CREATE PROCEDURE MYMARRIAGE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;@ BRIDEGROOM CHAR(NOTBAD) ,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;@ BRIDE CHAR(GOOD)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:arial;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;AS BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:arial;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;SELECT BRIDE FROM INDIA_BRIDES&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;WHERE FATHERINLAW = 'MILLIONAIRE'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;AND CARCOUNT &gt; 2 AND HOUSESTATUS ='TWOSTOREYED'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;AND BRIDEEDUSTATUS='PG ORABOVE'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;AND HAVINGBROTHERS='NO'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;AND HAVINGSISTERS ='NO'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;AND ALLOWRELOCATE ='YES' &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;SELECT GOLD ,CASH,CAR,BANKBALANE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;FROM FATHERINLAW&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;UPDATE MYBANKACCOUT SET MYBAL = MYBAL + FATHERINLAWBAL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;UPDATE MYLOCKER SET MYLOCKERCONTENTS = MYLOCKERCONTENTS + FATHERINLAWGOLD&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;INSERT INTO MYCARSHED VALUES ('BMW')&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:arial;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:arial;font-size:13px;"&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then the wife writes the below query:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;DROP HUSBAND&lt;/div&gt;&lt;div&gt;COMMIT;&lt;/div&gt;&lt;div&gt;  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;ha ha ha ha..Enjoy!!!!!&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-124456506681368722?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/124456506681368722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=124456506681368722' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/124456506681368722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/124456506681368722'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/06/just-found-this-funny-plsql-wedding.html' title='Funny SQL Query!'/><author><name>Thinking SQL Team</name><uri>http://www.blogger.com/profile/03693514797016716029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-880052876790185905</id><published>2009-06-01T09:12:00.000+03:00</published><updated>2009-06-01T09:26:19.042+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='useful scripts'/><category scheme='http://www.blogger.com/atom/ns#' term='Unused objects'/><title type='text'>Finding unused tables in SQL Server</title><content type='html'>&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Here's a query which can give you a clear idea about the unused tables in your database.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;t.name as 'table', &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;sum(i.user_seeks + i.user_scans + i.user_lookups)  as 'total accesses',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;sum(i.user_seeks) as 'seeks',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;sum(i.user_scans) as 'scans',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;sum(i.user_lookups) as 'lookups'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;from &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;sys.dm_db_index_usage_stats i right outer join &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;sys.tables t on (t.object_id = i.object_id)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;group by &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;i.object_id, &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;t.name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;order by [total accesses] desc&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;This works in SQL server 2005/later&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-880052876790185905?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/880052876790185905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=880052876790185905' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/880052876790185905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/880052876790185905'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/finding-unused-tables-in-sql-server.html' title='Finding unused tables in SQL Server'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-1451121118283210063</id><published>2009-05-22T14:37:00.000+03:00</published><updated>2009-05-22T15:57:33.879+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SET'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>SET vs SELECT !</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;SQL programmers  generally use SET/SELECT to assign the values to the variables.The following are the notable differences between SET and SELECT.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;1.In SELECT,more than one variable can be used&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;declare @name varchar(36),@grade varchar(3)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select @name='john',@grade = '10'&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;on the other hand in SET ,only one variable can be used at a time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;declare @name varchar(36),@grade varchar(3)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;set @name='john'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;set @grade='10'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;2. SELECT can perform better than SET statement,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;here's the test code to check the performance of the SET and SELECT.Its better test this in your local machine instead of the production server.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;declare @startime datetime ,@i varchar(1000),@j bigint  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;set @startime = current_timestamp &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;set @j = 50000 &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;while @j &gt; 0 &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;begin  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;set @i='myteststring'  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;set @j = @j -1 &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;end  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;SELECT datediff(ms, @Startime, CURRENT_TIMESTAMP) AS 'Time taken by SET in ms'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select @startime = current_timestamp&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select @j = 50000 &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;while @j &gt; 0 &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;begin  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select @i='myteststring'  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select @j = @j -1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;end &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select datediff(ms, @Startime, CURRENT_TIMESTAMP) AS 'Time taken by SELECT in ms'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;3.When assigning from a query if there's no value returned SET will assign a NULL ,whereas SELELCT will ignore the statement, the variable will return the previous value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;declare @myvar varchar(10)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;set @myvar = 'TEST'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;set @myvar = (select name from sysobjects where 1&lt;&gt;1)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select @myvar&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;this block of code will return NULL,but the below code will return 'TEST'.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;declare @myvar varchar(10)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select @myvar = 'TEST'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select @myvar= name from sysobjects where 1&lt;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select @myvar&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Conclusion : SET can be used when you want follow the coding standard and performance is not an issue.SELECT can be used when performance is a concern.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;      &lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-1451121118283210063?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/1451121118283210063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=1451121118283210063' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/1451121118283210063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/1451121118283210063'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/set-vs-select.html' title='SET vs SELECT !'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-3500469576062894965</id><published>2009-05-20T14:21:00.000+03:00</published><updated>2009-05-20T14:31:09.442+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips and Tricks'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Basics'/><title type='text'>How to Find Recently Executed Queries In SQL Server 2005</title><content type='html'>&lt;p style="font-family: georgia;"&gt;&lt;span style="font-size:100%;"&gt;Today I came  across a situation which required to find out recently executed queries to analyse the modifications carried out on a database server. &lt;/span&gt;&lt;/p&gt; &lt;p style="font-family: georgia;"&gt;&lt;span style="font-size:100%;"&gt;Here is the query which we used to find out the recently executed queries along with the date and time at which they were executed&lt;/span&gt;&lt;/p&gt; &lt;p style="font-family: georgia;"&gt; &lt;/p&gt;&lt;div    style="background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-family: georgia;font-family:courier new;font-size:8pt;color:black;"&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:blue;"&gt;SELECT&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:100%;"&gt;    DMExQryStats.last_execution_time &lt;span style="color:blue;"&gt;AS &lt;/span&gt;[Executed At],&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:100%;"&gt;    DMExSQLTxt.text &lt;span style="color:blue;"&gt;AS &lt;/span&gt;[Query]&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:blue;"&gt;FROM&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:100%;"&gt;    sys.dm_exec_query_stats &lt;span style="color:blue;"&gt;AS &lt;/span&gt;DMExQryStats&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:100%;"&gt;CROSS APPLY&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:100%;"&gt;    sys.dm_exec_sql_text(DMExQryStats.sql_handle) &lt;span style="color:blue;"&gt;AS &lt;/span&gt;DMExSQLTxt&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:blue;"&gt;ORDER BY&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="font-size:100%;"&gt;    DMExQryStats.last_execution_time &lt;span style="color:blue;"&gt;DESC&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style="font-family: georgia;"&gt;&lt;span style="font-size:100%;"&gt;Hope this will be useful to you also.&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-3500469576062894965?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/3500469576062894965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=3500469576062894965' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3500469576062894965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3500469576062894965'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/how-to-find-recently-executed-queries.html' title='How to Find Recently Executed Queries In SQL Server 2005'/><author><name>Mohammad Shahanshah Ansari</name><uri>http://www.blogger.com/profile/06767252392003510457</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/_js--bpISygk/SXOQyD1NKWI/AAAAAAAAAH0/VPWosz_6kuk/S220/Image005.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-3956612243305100853</id><published>2009-05-19T21:36:00.001+03:00</published><updated>2009-05-19T22:47:51.106+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SELECT INTO'/><category scheme='http://www.blogger.com/atom/ns#' term='INDEXES'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Copying table with the Indexes</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;SELECT INTO statement can be useful in the following scenarios.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;1.Create a new table with same structure of the existing table&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;2.Copy all/some records from existing table to a new table&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;This leads to the question, w&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;ill SELECT INTO copy the indexes and keys?&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;.&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;No.&lt;/span&gt;&lt;/span&gt;The new table created using SELECT INTO will not have indexes,primary key,foreign keys,default values and triggers.I find these reasons why Microsoft not implemented this feature of copying indexes in SELECT INTO:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;i). Its not the best practice to create the indexes while creating the tables.You can determine the columns to be indexed while facing the serious performance issue.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;ii).Indexes cannot be created in the same name like how column names are similar while copying a table using SELECT INTO.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;But &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;SSIS&lt;/span&gt; provides the solution to copy the table with the indexes.We will see how to implement this in the future post.When you want to copy the huge amount of data , better go for &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;DTS&lt;/span&gt; or Import/Export wizard (make sure that you script out the table structure).It is certainly faster than SELECT INTO.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-3956612243305100853?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/3956612243305100853/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=3956612243305100853' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3956612243305100853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3956612243305100853'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/copying-table-with-indexes.html' title='Copying table with the Indexes'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-7147556161897145352</id><published>2009-05-19T09:57:00.001+03:00</published><updated>2009-05-19T10:03:05.667+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sql Server Loading'/><title type='text'>Different Options for Importing Data into SQL Server</title><content type='html'>&lt;h1 style="font-family: trebuchet ms;"&gt;&lt;span style="font-size: 12pt;"&gt;Different Options for Importing Data into SQL Server&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;p style="margin-bottom: 12pt; font-family: trebuchet ms;"&gt;&lt;b&gt;&lt;u&gt;Problem&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;Moving data into SQL Server is something that most DBAs or Developers are faced with probably on a daily basis.  One simple way of doing this is by using the Import / Export wizard, but along with this option there are several other ways of loading data into SQL Server tables. Another common technique would be to use either DTS (SQL 2000) or SSIS (SQL 2005).  In this tip we take a look at some of these other options for importing data into SQL Server.&lt;/p&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;b&gt;&lt;u&gt;Solution&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;In addition to using the Import / Export wizards and/or DTS or SSIS to move data into SQL Server there are also a few other options for doing this that are built into SQL Server.  Some these other options include bcp, BULK INSERT, OPENROWSET as well as others.  The following examples show you some of these different options for importing data and how you can use some of these inline with your T-SQL code as well as others that can be run from the command line.&lt;/p&gt;  &lt;div class="MsoNormal" style="text-align: center; font-family: trebuchet ms;" align="center"&gt;  &lt;hr align="center" size="2" width="100%"&gt;  &lt;/div&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;a style="font-weight: bold;" href="http://msdn2.microsoft.com/en-us/library/ms162802.aspx" target="_blank"&gt;BCP&lt;/a&gt;&lt;br /&gt;This is one of the options that is mostly widely used.  One reason for this is that it has been around for awhile, so DBAs have come quite familiar with this command.  This command allows you to both import and export data, but is primarily used for text data formats.  In addition, this command is generally run from a Windows command prompt, but could also be called from a stored procedure by using xp_cmdshell or called from a DTS or SSIS package.&lt;/p&gt;  &lt;p style="font-family: trebuchet ms;"&gt;Here is a simple command for importing data from file C:\ImportData.txt into table dbo.ImportTest.&lt;/p&gt;  &lt;div style="font-family: trebuchet ms;" align="center"&gt;  &lt;table class="MsoNormalTable" style="width: 80%;" border="1" cellpadding="0" cellspacing="0" width="80%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 3.75pt;" valign="top"&gt;   &lt;p&gt;&lt;span style="color: blue;"&gt;bcp dbo.ImportTest in   'C:\ImportData.txt' -T -SserverName\instanceName&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;    &lt;div class="MsoNormal" style="text-align: center; font-family: trebuchet ms;" align="center"&gt;  &lt;hr align="center" size="2" width="100%"&gt;  &lt;/div&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;a style="font-weight: bold;" href="http://msdn2.microsoft.com/en-us/library/ms188365.aspx" target="_blank"&gt;BULK INSERT&lt;/a&gt;&lt;br /&gt;This command is a T-SQL command that allows you to import data directly from within SQL Server by using T-SQL.  This command imports data from file C:\ImportData.txt into table dbo.ImportTest.&lt;/p&gt;  &lt;div style="font-family: trebuchet ms;" align="center"&gt;  &lt;table class="MsoNormalTable" style="width: 80%;" border="1" cellpadding="0" cellspacing="0" width="80%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 3.75pt;" valign="top"&gt;   &lt;p&gt;&lt;span style="color: blue;"&gt;BULK INSERT   dbo.ImportTest&lt;br /&gt;  FROM 'C:\ImportData.txt'&lt;br /&gt;  WITH ( FIELDTERMINATOR =',', FIRSTROW = 2 )&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;    &lt;div class="MsoNormal" style="text-align: center; font-family: trebuchet ms;" align="center"&gt;  &lt;hr align="center" size="2" width="100%"&gt;  &lt;/div&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;a style="font-weight: bold;" href="http://msdn2.microsoft.com/en-us/library/ms190312.aspx" target="_blank"&gt;OPENROWSET&lt;/a&gt;&lt;br /&gt;This command is a T-SQL command that allows you to query data from other data sources directly from within SQL Server.  By using this command along with an INSERT INTO command we can load data from the specified data source into a SQL Server table.&lt;/p&gt;  &lt;p style="font-family: trebuchet ms;"&gt;This command will pull in all data from worksheet [Sheet1$]. By using the INSERT INTO command you can insert the query results into table dbo.ImportTest.&lt;/p&gt;  &lt;div style="font-family: trebuchet ms;" align="center"&gt;  &lt;table class="MsoNormalTable" style="width: 80%;" border="1" cellpadding="0" cellspacing="0" width="80%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 3.75pt;" valign="top"&gt;   &lt;p&gt;&lt;span style="color: blue;"&gt;INSERT INTO   dbo.ImportTest&lt;br /&gt;  SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',&lt;br /&gt;  'Excel 8.0;Database=C:\ImportData.xls', [Sheet1$]) &lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;  &lt;p style="font-family: trebuchet ms;"&gt;Here is another example where data is pulled from worksheet [Sheet1$] by using a SELECT * FROM command. Again, by using the INSERT INTO command you can insert the query results into table dbo.ImportTest.   The query can be any valid SQL query, so you can filter the columns and rows by using this option.&lt;/p&gt;  &lt;div style="font-family: trebuchet ms;" align="center"&gt;  &lt;table class="MsoNormalTable" style="width: 80%;" border="1" cellpadding="0" cellspacing="0" width="80%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 3.75pt;" valign="top"&gt;   &lt;p&gt;&lt;span style="color: blue;"&gt;INSERT INTO   dbo.ImportTest&lt;br /&gt;  SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',&lt;br /&gt;  'Excel 8.0;Database=C:\ImportData.xls', 'SELECT * FROM [Sheet1$]')&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;    &lt;div class="MsoNormal" style="text-align: center; font-family: trebuchet ms;" align="center"&gt;  &lt;hr align="center" size="2" width="100%"&gt;  &lt;/div&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;a style="font-weight: bold;" href="http://msdn2.microsoft.com/en-us/library/ms179856.aspx" target="_blank"&gt;OPENDATASOURCE&lt;/a&gt;&lt;br /&gt;This command is a T-SQL command that allows you to query data from other data sources directly from within SQL Server. This is similar to the OPENROWSET command.&lt;/p&gt;  &lt;div style="font-family: trebuchet ms;" align="center"&gt;  &lt;table class="MsoNormalTable" style="width: 80%;" border="1" cellpadding="0" cellspacing="0" width="80%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 3.75pt;" valign="top"&gt;   &lt;p&gt;&lt;span style="color: blue;"&gt;INSERT INTO   dbo.ImportTest&lt;br /&gt;  SELECT * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',&lt;br /&gt;  'Data Source=C:\ImportData.xls;Extended Properties=Excel 8.0')...[Sheet1$]&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;    &lt;div class="MsoNormal" style="text-align: center; font-family: trebuchet ms;" align="center"&gt;  &lt;hr align="center" size="2" width="100%"&gt;  &lt;/div&gt;  &lt;p style="font-family: trebuchet ms;"&gt;&lt;a style="font-weight: bold;" href="http://msdn2.microsoft.com/en-us/library/ms188427.aspx" target="_blank"&gt;OPENQUERY&lt;/a&gt;&lt;br /&gt;Another option is OPENQUERY.  This is another command that allows you to issue a T-SQL command to select data and again with the INSERT INTO option we can load data into our table.  There are two steps with this process, first a linked server is setup and then second the query is issued using the OPENQUERY command.  This option allow you to filter the columns and rows by the query that is issued against your linked data source.&lt;/p&gt;  &lt;div style="font-family: trebuchet ms;" align="center"&gt;  &lt;table class="MsoNormalTable" style="width: 80%;" border="1" cellpadding="0" cellspacing="0" width="80%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 3.75pt;" valign="top"&gt;   &lt;p&gt;&lt;span style="color: blue;"&gt;EXEC sp_addlinkedserver   'ImportData',&lt;br /&gt;     'Jet 4.0', 'Microsoft.Jet.OLEDB.4.0',&lt;br /&gt;     'C:\ImportData.xls',&lt;br /&gt;     NULL,&lt;br /&gt;     'Excel 8.0'&lt;br /&gt;  GO&lt;/span&gt; &lt;/p&gt;   &lt;p&gt;&lt;span style="color: blue;"&gt;INSERT INTO   dbo.ImportTest&lt;br /&gt;  SELECT *&lt;br /&gt;  FROM OPENQUERY(ImportData, 'SELECT * FROM [Sheet1$]') &lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;    &lt;p style="font-family: trebuchet ms;"&gt;&lt;a style="font-weight: bold;" href="http://msdn2.microsoft.com/en-us/library/ms190479.aspx" target="_blank"&gt;Linked Servers&lt;/a&gt;&lt;br /&gt;Here is yet another option with setting up a linked server and then issuing a straight SQL statement against the linked server.  This again has two steps, first the linked server is setup and secondly a SQL command is issued against the linked data source.&lt;/p&gt;  &lt;div style="font-family: trebuchet ms;" align="center"&gt;  &lt;table class="MsoNormalTable" style="width: 80%;" border="1" cellpadding="0" cellspacing="0" width="80%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 3.75pt;" valign="top"&gt;   &lt;p&gt;&lt;span style="color: blue;"&gt;EXEC sp_addlinkedserver   'ImportData',&lt;br /&gt;     'Jet 4.0', 'Microsoft.Jet.OLEDB.4.0',&lt;br /&gt;     'C:\ImportData.xls',&lt;br /&gt;     NULL,&lt;br /&gt;     'Excel 8.0'&lt;br /&gt;  GO&lt;/span&gt; &lt;/p&gt;   &lt;p&gt;&lt;span style="color: blue;"&gt;INSERT INTO   dbo.ImportTest&lt;br /&gt;  SELECT * FROM ImportData...Sheet1$&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;  &lt;p style="font-family: trebuchet ms;"&gt; &lt;/p&gt;  &lt;p style="font-family: trebuchet ms;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-7147556161897145352?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/7147556161897145352/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=7147556161897145352' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/7147556161897145352'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/7147556161897145352'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/different-options-for-importing-data.html' title='Different Options for Importing Data into SQL Server'/><author><name>Karthick Mahalingam</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_sW3kGC68HzA/S-ElZqKmMFI/AAAAAAAAAAM/qVXd_FuWeSI/S220/index.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-1873997414924331901</id><published>2009-05-18T21:41:00.000+03:00</published><updated>2009-05-18T22:23:52.807+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Certification'/><category scheme='http://www.blogger.com/atom/ns#' term='Prometric'/><title type='text'>SQL Server 2008 certification path</title><content type='html'>&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Download the SQL server (2008) certification path &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;a href="http://download.microsoft.com/download/6/3/7/6370c653-e270-4e23-9685-15043f63dcce/SQLServer2008_CertPath_Complete.pdf"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;here&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;.&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;It will be handy if you have any idea of taking Microsoft SQL server certification.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Don't forget, there is a &lt;/span&gt;&lt;a href="http://www.microsoft.com/learning/mcp/offers/secondshot/default.mspx"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;second shot offer&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; available for selected exams till &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;June 30,2009.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;You can take these exams in &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Bangalore &lt;/span&gt;@&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;NIIT&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;#143-B,II Floor , 5th Block,   &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;60 Feet Road,Koramangala&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Bangalore.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;In &lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;chennai &lt;/span&gt;@,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;NIIT&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Shah Complex, 59, L B Road,Adyar,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Near Adyar Bus terminal.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Chennai.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Homson prometric testing (p) ltd&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;No 15,II floor,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Romar house,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Jagannathan road,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Nungambakkam,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Chennai.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span&gt;&lt;span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Check the nearest &lt;a href="http://www.prometric.com/Microsoft/default.htm"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;Prometric services&lt;/span&gt;&lt;/a&gt; for more information about exam centers.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-1873997414924331901?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/1873997414924331901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=1873997414924331901' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/1873997414924331901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/1873997414924331901'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/sql-server-2008-certification-path.html' title='SQL Server 2008 certification path'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-3247775267674463402</id><published>2009-05-17T10:46:00.000+03:00</published><updated>2009-05-17T19:52:09.110+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='Strings'/><title type='text'>Text Concatenation in SQL Server</title><content type='html'>To concate the Text for a combination of keys there might be many ways.&lt;br /&gt;&lt;br /&gt;Initially I was  using either function or cursor for concatenation. But finally I found the below query most useful for the same.&lt;br /&gt;&lt;br /&gt;First Create a table called Product with the following data.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_js--bpISygk/ShBAHBcnbcI/AAAAAAAAAOQ/DDd5O-xc-wI/s1600-h/query1.gif"&gt;&lt;img style="cursor: pointer; width: 134px; height: 173px;" src="http://2.bp.blogspot.com/_js--bpISygk/ShBAHBcnbcI/AAAAAAAAAOQ/DDd5O-xc-wI/s400/query1.gif" alt="" id="BLOGGER_PHOTO_ID_5336836047825759682" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Don't forget to create index if your table has huge data.&lt;br /&gt;&lt;br /&gt;Then run the below Query:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;SELECT&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;DISTINCT T.ID&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;,(SELECT ' ' + [DESC] FROM &lt;span style="color: rgb(0, 0, 0);"&gt;PRODUCT &lt;/span&gt;WHERE ID = T.ID FOR XML PATH('')) AS [DESC] FROM &lt;span style="color: rgb(0, 0, 0);"&gt;PRODUCT &lt;/span&gt;T&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You will get the output as:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_js--bpISygk/ShA_9b-mYnI/AAAAAAAAAOI/ePF1c3UpCuA/s1600-h/query2.gif"&gt;&lt;img style="cursor: pointer; width: 353px; height: 75px;" src="http://2.bp.blogspot.com/_js--bpISygk/ShA_9b-mYnI/AAAAAAAAAOI/ePF1c3UpCuA/s400/query2.gif" alt="" id="BLOGGER_PHOTO_ID_5336835883148927602" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I hope this will help you guys. Share if you have any other good alternative.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-3247775267674463402?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/3247775267674463402/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=3247775267674463402' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3247775267674463402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/3247775267674463402'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/text-concatenation-in-sql-server.html' title='Text Concatenation in SQL Server'/><author><name>Mohammad Shahanshah Ansari</name><uri>http://www.blogger.com/profile/06767252392003510457</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/_js--bpISygk/SXOQyD1NKWI/AAAAAAAAAH0/VPWosz_6kuk/S220/Image005.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_js--bpISygk/ShBAHBcnbcI/AAAAAAAAAOQ/DDd5O-xc-wI/s72-c/query1.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-5183122116309247847</id><published>2009-05-17T10:23:00.000+03:00</published><updated>2009-05-17T21:27:59.494+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NEWID()'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><title type='text'>Selecting random records in SQL Server</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Here's a way to select the random records from a table&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;select &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;top 5 name &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;from&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;sys.objects&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;order by&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;newid()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;This query will return 5 random tables from sys.objects each time you execute it.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Know more about newid()&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa276822(SQL.80).aspx"&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 153);"&gt;here&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-5183122116309247847?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/5183122116309247847/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=5183122116309247847' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/5183122116309247847'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/5183122116309247847'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/selecting-random-records-in-sql-server.html' title='Selecting random records in SQL Server'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-475082953049731651</id><published>2009-05-15T19:10:00.000+03:00</published><updated>2009-05-15T19:49:26.150+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Basics'/><title type='text'>Inserting multiple records using single insert statement</title><content type='html'>An Interesting topic with Insert statement,&lt;br /&gt;&lt;br /&gt; Is it possible to insert multiple records using one single insert statement?&lt;br /&gt;&lt;br /&gt;Most of the programmers will say 'NO' But&lt;br /&gt;&lt;br /&gt;Let's see,&lt;span style="color: rgb(0, 153, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;IF EXISTS &lt;/span&gt;(SELECT &lt;span style="color: rgb(0, 0, 0);"&gt;NAME &lt;/span&gt;FROM &lt;span style="color: rgb(0, 51, 0);"&gt;SYSOBJECTS &lt;/span&gt;WHERE &lt;span style="color: rgb(0, 0, 0);"&gt;NAME&lt;/span&gt;=&lt;span style="color: rgb(255, 0, 0);"&gt;'EMP' &lt;/span&gt;AND TYPE=&lt;span style="color: rgb(255, 0, 0);"&gt;'U'&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;DROP TABLE EMP&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;CREATE TABLE &lt;span style="color: rgb(0, 0, 0);"&gt;EMP&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 0);"&gt;ID &lt;/span&gt;INT, &lt;span style="color: rgb(0, 0, 0);"&gt;NAME &lt;/span&gt;VARCHAR&lt;span style="color: rgb(0, 0, 0);"&gt;(10))&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;INSERT INTO EMP&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;SELECT 1,&lt;span style="color: rgb(255, 0, 0);"&gt;'ANSARI'&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;&lt;br /&gt;UNION ALL&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;SELECT 2,&lt;span style="color: rgb(255, 0, 0);"&gt;'MAGESH'&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;&lt;br /&gt;UNION ALL&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;SELECT 3,&lt;span style="color: rgb(255, 0, 0);"&gt;'ANOOP'&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;&lt;br /&gt;UNION ALL&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;SELECT 4,&lt;span style="color: rgb(255, 0, 0);"&gt;'SARAVANA'&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;&lt;br /&gt;UNION ALL&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;SELECT 5,&lt;span style="color: rgb(255, 0, 0);"&gt;'PRASANNA'&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;&lt;br /&gt;UNION ALL&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;SELECT 6,&lt;span style="color: rgb(255, 0, 0);"&gt;'FAHAD'&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;&lt;br /&gt;UNION ALL&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;SELECT 7,&lt;span style="color: rgb(255, 0, 0);"&gt;'KARTHICK'&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;&lt;br /&gt;UNION ALL&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;SELECT 8,&lt;span style="color: rgb(255, 0, 0);"&gt;'VIJAY'&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;&lt;br /&gt;UNION &lt;span style="color: rgb(0, 0, 0);"&gt;ALL&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;SELECT 9,&lt;span style="color: rgb(255, 0, 0);"&gt;'SAHIL'&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;SELECT * FROM &lt;span style="color: rgb(0, 0, 0);"&gt;EMP&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_js--bpISygk/Sg2c-zb-3rI/AAAAAAAAANI/pOlr69A8GEg/s1600-h/table.gif"&gt;&lt;img style="cursor: pointer; width: 131px; height: 189px;" src="http://1.bp.blogspot.com/_js--bpISygk/Sg2c-zb-3rI/AAAAAAAAANI/pOlr69A8GEg/s400/table.gif" alt="" id="BLOGGER_PHOTO_ID_5336093736277302962" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-475082953049731651?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/475082953049731651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=475082953049731651' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/475082953049731651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/475082953049731651'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/inserting-multiple-records-using-single.html' title='Inserting multiple records using single insert statement'/><author><name>Mohammad Shahanshah Ansari</name><uri>http://www.blogger.com/profile/06767252392003510457</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/_js--bpISygk/SXOQyD1NKWI/AAAAAAAAAH0/VPWosz_6kuk/S220/Image005.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_js--bpISygk/Sg2c-zb-3rI/AAAAAAAAANI/pOlr69A8GEg/s72-c/table.gif' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-7378049969991939968</id><published>2009-05-15T17:10:00.001+03:00</published><updated>2009-05-15T17:15:19.434+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='INDEXES'/><title type='text'>Copy table with Indexes</title><content type='html'>Hey Guys,&lt;br /&gt;&lt;br /&gt;We create a copy of table using SELECT INTO .. query, but we know that it doesn't carry the indexes to the new table.&lt;br /&gt;&lt;br /&gt;Suggest the different ways for carrying the Indexes to the new table that we are copying...&lt;br /&gt;&lt;br /&gt;Thanks in advance&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-7378049969991939968?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/7378049969991939968/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=7378049969991939968' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/7378049969991939968'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/7378049969991939968'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/copy-table-with-indexes.html' title='Copy table with Indexes'/><author><name>Saravana Kumar</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-5183509414009453365</id><published>2009-05-15T13:11:00.000+03:00</published><updated>2009-05-15T13:27:58.588+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='User tables'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Basics'/><title type='text'>Finding user tables</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: medium;"&gt;The are three best possible ways to find the "&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;user tables&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;" in SQL Server.&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&gt; &lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;SELECT &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;NAME&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;   &lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;FROM&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;  &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;SYS.OBJECTS&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;  &lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;WHERE&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 51, 204);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;TYPE&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;=&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;'U'&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;SELECT &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;*  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;FROM &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;INFORMATION_SCHEMA.TABLES&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;WHERE &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;TABLE_TYPE=&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;'BASE TABLE'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;EXEC &lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;SP_TABLES&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; @TABLE_TYPE="'TABLE'"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Comment the one that you use often and the other ways to find the user tables.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-5183509414009453365?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/5183509414009453365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=5183509414009453365' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/5183509414009453365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/5183509414009453365'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/finding-user-tables.html' title='Finding user tables'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-6937413267335972629</id><published>2009-05-15T01:15:00.001+03:00</published><updated>2009-05-15T08:57:00.304+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Collation'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Basics'/><title type='text'>Case Sensitivity in SQL Server</title><content type='html'>&lt;div style="text-align: justify;"&gt;It’s always pain in the neck when it comes to case sensitive programming. A very common question would come across in every SQL server newbie: Is T-SQL case-sensitive?&lt;br /&gt;&lt;br /&gt;The Answer is “&lt;span style="font-weight: bold;"&gt;NO&lt;/span&gt;”. The following two statements will produce the same results without any error.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;i)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102); font-weight: bold;"&gt;               SELECT        *&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-weight: bold;"&gt;               FROM&lt;/span&gt;&lt;span style="color: rgb(0, 51, 0); font-weight: bold;"&gt;           SYS.OBJECTS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ii)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;               select            *&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;               from &lt;span style="color: rgb(0, 51, 0);"&gt;sys.objects&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But will the following statements produce the same result?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;             SELECT         *&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;             FROM             &lt;span style="color: rgb(0, 0, 0);"&gt;STUDENT&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-weight: bold;"&gt;             WHERE         &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;NAME =&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt; 'JOHN'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;            SELECT         *&lt;/span&gt;&lt;br /&gt;     &lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;FROM            &lt;span style="color: rgb(0, 0, 0);"&gt;STUDENT&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0, 0, 153); font-weight: bold;"&gt;WHERE          &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;NAME =&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt; 'john&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The answer is “it depends on the collation” as our search string differs in case sensitivity.&lt;br /&gt;&lt;br /&gt;In simple words collation in SQL server&lt;span style="font-style: italic; font-weight: bold;"&gt; &lt;/span&gt;is&lt;span style="font-style: italic; font-weight: bold;"&gt; &lt;span style="color: rgb(0, 0, 102);"&gt;a set of rules that determine how data is sorted and compared&lt;/span&gt;&lt;/span&gt;. We can make the search string as case sensitive in SQL server. Let’s check the collation of the current database.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102); font-weight: bold;"&gt;          SELECT &lt;/span&gt;&lt;span style="color: rgb(204, 51, 204); font-weight: bold;"&gt;DATABASEPROPERTYEX(DB_NAME()&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;,'&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;COLLATION&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;')&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The collation in my test database is,&lt;br /&gt;SQL_Latin1_General_CP1_CI_AS&lt;br /&gt;&lt;br /&gt;Here CI specifies Case Insensitive.&lt;br /&gt;&lt;br /&gt;SP_HELP can be used to identify the table &amp;amp; column level collation.Some of the other possible collations are:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;SQL_Latin1_General_Cp437_CS_AS (CS specifies case-sensitive).&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;SQL_Latin1_General_Pref_CP1_CI_AS&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;SQL_Hungarian_Cp1250_CI_AS&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;SQL_Croatian_Cp1250_CI_AS&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;SQL_Latin1_General_Cp1254_CI_AS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Our counterpart PL/SQL is also not case sensitive, so lower case letters are equivalent to corresponding upper-case letters except within string and character literals. This is what differentiates PL/SQL and T_SQL in case-sensitivity. The Collation can be changes as the project requires. But when its comes to whether to use all Caps or all smalls in T-SQL , its better be consistent throughout the scripts.It facilitates more readability.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Happy reading!&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-6937413267335972629?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/6937413267335972629/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=6937413267335972629' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/6937413267335972629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/6937413267335972629'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/case-sensitivity-in-sql-server_3313.html' title='Case Sensitivity in SQL Server'/><author><name>The Trainer</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8913659610460375389.post-375682934428569339</id><published>2009-05-14T09:16:00.000+03:00</published><updated>2009-05-14T14:50:55.748+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Basics'/><title type='text'>Why SQL Server ?</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(0, 0, 0);font-size:100%;" &gt;Dear Friends,&lt;br /&gt;&lt;br /&gt;Just to begin with this blog I will share some information on what is SQL server and why we choose SQL Server. Let us know if you like this post.&lt;br /&gt;&lt;br /&gt;SQL Server&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:100%;" &gt; is a relational database management system (RDBMS) from Microsoft that's designed for the enterprise environment. SQL Server runs on T-SQL (Transact -SQL), a set of programming extensions from Sybase and Microsoft that add several features to standard SQL, including transaction control, exception and error handling, row processing, and declared variables.&lt;br /&gt;&lt;br /&gt;Codenamed Yukon in development, SQL Server 2005 was released in November 2005. The 2005 product is said to provide enhanced flexibility, scalability, reliability, and security to database applications, and to make them easier to create and deploy, thus reducing the complexity and tedium involved in database management. SQL Server 2005 also includes more administrative support.&lt;br /&gt;&lt;br /&gt;The original SQL Server code was developed by Sybase; in the late 1980s, Microsoft, Sybase and Ashton-Tate collaborated to produce the first version of the product, SQL Server 4.2 for OS/2. Subsequently, both Sybase and Microsoft offered SQL Server products. Sybase has since renamed their product Adaptive Server Enterprise.&lt;br /&gt;&lt;br /&gt;Generically, any database management system (DBMS) that can respond to queries from client machines formatted in the SQL language. When capitalized, the term generally refers to either of two database management products from Sybase and Microsoft. Both companies offer client-server DBMS products called SQL Server.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);font-size:100%;" &gt;SQL Server 2005 is the Data Platform leader&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;br /&gt;• Microsoft SQL Server 2005 is comprehensive, integrated data management and analysis software that enables organizations to reliably manage mission-critical information and confidently run today’s increasingly complex business applications. SQL Server 2005 allows companies to gain greater insight from their business information and achieve faster results for a competitive advantage.&lt;br /&gt;•    SQL Server is the fastest growing Database and Business Intelligence vendor&lt;br /&gt;•    SQL Server ships more units than Oracle and IBM combined.&lt;br /&gt;•    SQL Server is the #1 OLAP Server on the market.&lt;br /&gt;• SQL Server is more secure than Oracle. Since July 2003 more than 100 critical Oracle database security vulnerabilities have been identified, compared to ZERO for SQL Server for that period.&lt;br /&gt;•    SQL Server is best in price/performance for TPC-H 1TB &amp;amp; 3TB (non-clustered).&lt;br /&gt;•    Microsoft SQL Server and Unisys are the first to publish TPC-E benchmark results.&lt;br /&gt;• Gartner 2006 worldwide RDBMS market share reports highest growth rate in market share for Microsoft SQL Server. With 28% growth in market share, growth is almost twice the nearest competitor at 14.8% growth.&lt;br /&gt;Microsoft SQL Server is a relational model database server produced by Microsoft. Its primary query languages are T-SQL and ANSI SQL.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8913659610460375389-375682934428569339?l=think-sql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://think-sql.blogspot.com/feeds/375682934428569339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8913659610460375389&amp;postID=375682934428569339' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/375682934428569339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8913659610460375389/posts/default/375682934428569339'/><link rel='alternate' type='text/html' href='http://think-sql.blogspot.com/2009/05/why-sql-server.html' title='Why SQL Server ?'/><author><name>Mohammad Shahanshah Ansari</name><uri>http://www.blogger.com/profile/06767252392003510457</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/_js--bpISygk/SXOQyD1NKWI/AAAAAAAAAH0/VPWosz_6kuk/S220/Image005.jpg'/></author><thr:total>1</thr:total></entry></feed>
