<?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:blogger='http://schemas.google.com/blogger/2008' 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-4095189091918776754</id><updated>2025-11-21T00:57:20.011-08:00</updated><title type='text'>SQL Question and Answers</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>173</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-2163387169353460774</id><published>2013-05-15T03:19:00.001-07:00</published><updated>2013-05-15T03:19:51.813-07:00</updated><title type='text'>SQL SERVER – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;posttitle&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 0px; padding: 0px;&quot;&gt;
&lt;div class=&quot;post-info&quot; style=&quot;background-image: url(http://s1.wp.com/wp-content/themes/pub/mistylook/img/underline1.jpg); background-position: 0% 100%; background-repeat: no-repeat no-repeat; color: #999999; font-size: 0.9em; line-height: 1.6em; padding: 0px 0px 12px;&quot;&gt;
March 5, 2007 by&amp;nbsp;&lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; style=&quot;color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 1em 0px; overflow: hidden; padding: 0px 1em 0px 0px;&quot;&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
When create or alter SQL object like Stored Procedure, User Defined Function in Query Analyzer, it is created with following SQL commands prefixed and suffixed. What are these – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF?&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SET&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;QUOTED_IDENTIFIER&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SET&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;ANSI_NULLS&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--SQL PROCEDURE, SQL FUNCTIONS, SQL OBJECTGO&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SET&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;QUOTED_IDENTIFIER&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;OFF&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SET&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;ANSI_NULLS&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;ANSI NULL ON/OFF:&lt;/strong&gt;&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;This option specifies the setting for ANSI NULL comparisons. When this is on, any query that compares a value with a null returns a 0. When off, any query that compares a value with a null returns a null value.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;QUOTED IDENTIFIER ON/OFF:&lt;/strong&gt;&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;This options specifies the setting for usage of double quotation. When this is on, double quotation mark is used as part of the SQL Server identifier (object name). This can be useful in situations in which identifiers are also SQL Server reserved words.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Reference :&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Pinal Dave (&lt;/strong&gt;&lt;a href=&quot;http://blog.sqlauthority.com/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;http://blog.SQLAuthority.com&lt;/strong&gt;&lt;/a&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/2163387169353460774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/05/sql-server-quotedidentifier-onoff-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/2163387169353460774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/2163387169353460774'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/05/sql-server-quotedidentifier-onoff-and.html' title='SQL SERVER – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-1923520271742426141</id><published>2013-05-15T03:17:00.002-07:00</published><updated>2013-05-15T03:17:36.921-07:00</updated><title type='text'>SQL SERVER – Interview Questions and Answers – Frequently Asked Questions – Day 4 of 31</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;posttitle&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 0px; padding: 0px;&quot;&gt;
&lt;div class=&quot;post-info&quot; style=&quot;background-image: url(http://s1.wp.com/wp-content/themes/pub/mistylook/img/underline1.jpg); background-position: 0% 100%; background-repeat: no-repeat no-repeat; color: #999999; font-size: 0.9em; line-height: 1.6em; padding: 0px 0px 12px;&quot;&gt;
July 4, 2011 by&amp;nbsp;&lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; style=&quot;color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 1em 0px; overflow: hidden; padding: 0px 1em 0px 0px;&quot;&gt;
&lt;table class=&quot;sample&quot; style=&quot;border-spacing: 0px; border: 3px solid rgb(56, 79, 131); margin: 0px; padding: 0px;&quot;&gt;&lt;tbody style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;tr style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;td style=&quot;border: 0px dashed white; font-family: &#39;Segoe Print&#39;; font-size: 18px; font-weight: bold; margin: 0px; padding: 5px; text-align: center; width: 500px;&quot;&gt;SQL Server Interview Questions and Answers&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;td style=&quot;border: 0px dashed white; font-family: &#39;Segoe Print&#39;; font-size: 18px; font-weight: bold; margin: 0px; padding: 5px; text-align: center; width: 500px;&quot;&gt;&lt;a class=&quot;sample1&quot; href=&quot;http://bit.ly/sqlinterviewbook&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Print Book Available (207 Pages)&lt;/a&gt;&amp;nbsp;|&amp;nbsp;&lt;a class=&quot;sample1&quot; href=&quot;http://www.pinaldave.com/sql-downloads/pdf-download/sql-server-2008-interview-questions-and-answers-download/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Sample Chapters&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Please read the&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; text-decoration: underline;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://blog.sqlauthority.com/2011/07/01/sql-server-interview-questions-and-answers-frequently-asked-questions-introduction-day-1-of-31/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Introductory Post&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;before continue reading interview question and answers.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;a href=&quot;http://blog.sqlauthority.com/2011/07/01/sql-server-interview-questions-and-answers-frequently-asked-questions-complete-downloadable-list-day-0-of-31&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;List of all the Interview Questions and Answers Series blogs&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h2 style=&quot;font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; letter-spacing: 1px; margin: 1em 0px 0px; padding: 0px; text-align: justify;&quot;&gt;
What is the Difference between a Function and a Stored Procedure?&lt;/h2&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section, whereas Stored procedures cannot be. UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables. Inline UDF’s can be thought of as views that take parameters and can be used in JOINs and other Rowset operations.&lt;/div&gt;
&lt;h2 style=&quot;font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; letter-spacing: 1px; margin: 1em 0px 0px; padding: 0px; text-align: justify;&quot;&gt;
What is subquery? Explain the Properties of a Subquery?&lt;/h2&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Subqueries are often referred to as sub-selects as they allow a SELECT statement to be executed arbitrarily within the body of another SQL statement. A subquery is executed by enclosing it in a set of parentheses. Subqueries are generally used to return a single row as an atomic value although they may be used to compare values against multiple rows with the IN keyword.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
A subquery is a SELECT statement that is nested within another T-SQL statement. A subquery SELECT statement if executed independently of the T-SQL statement, in which it is nested, will return a resultset. This implies that a subquery SELECT statement can stand alone, and it does not depend on the statement in which it is nested. A subquery SELECT statement can return any number of values and can be found in the column list of a SELECT statement, and FROM, GROUP BY, HAVING, and/or ORDER BY clauses of a T-SQL statement. A subquery can also be used as a parameter to a function call. Basically, a subquery can be used anywhere an expression can be used. (&lt;a href=&quot;http://blog.sqlauthority.com/2007/09/07/sql-server-correlated-and-noncorrelated-subquery-introduction-explanation-and-example/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot;&gt;Read more here&lt;/a&gt;)&lt;/div&gt;
&lt;h2 style=&quot;font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; letter-spacing: 1px; margin: 1em 0px 0px; padding: 0px; text-align: justify;&quot;&gt;
What are Different Types of Join?&lt;/h2&gt;
&lt;h3 style=&quot;color: #384f83; font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; margin: 1em 0px 0px; padding: 0px; text-align: justify;&quot;&gt;
Cross Join&lt;/h3&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
A cross join that does not have a WHERE clause produces the Cartesian product of the tables involved in the join. The size of a Cartesian product result set is the number of rows in the first table multiplied by the number of rows in the second table. The common example is when company wants to combine each product with a pricing table to analyze each product at each price.&lt;/div&gt;
&lt;h3 style=&quot;color: #384f83; font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; margin: 1em 0px 0px; padding: 0px; text-align: justify;&quot;&gt;
Inner Join&lt;/h3&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
A join that displays only the rows that have a match in both joined tables is known as inner Join. This is the default type of join in the Query and View Designer.&lt;/div&gt;
&lt;h3 style=&quot;color: #384f83; font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; margin: 1em 0px 0px; padding: 0px; text-align: justify;&quot;&gt;
Outer Join&lt;/h3&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
A join that includes rows even if they do not have related rows in the joined table is an Outer Join. You can create three different outer join to specify the unmatched rows to be included:&lt;/div&gt;
&lt;ul style=&quot;list-style-image: url(http://s1.wp.com/wp-content/themes/pub/mistylook/img/bullet.png); margin: 1em; padding: 0px 1em; text-align: justify;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Left Outer Join: In Left Outer Join, all the rows in the first-named table, i.e. “left” table, which appears leftmost in the JOIN clause, are included. Unmatched rows in the right table do not appear.&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;list-style-image: url(http://s1.wp.com/wp-content/themes/pub/mistylook/img/bullet.png); margin: 1em; padding: 0px 1em; text-align: justify;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Right Outer Join: In Right Outer Join, all the rows in the second-named table, i.e. “right” table, which appears rightmost in the JOIN clause are included. Unmatched rows in the left table are not included.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;list-style-image: url(http://s1.wp.com/wp-content/themes/pub/mistylook/img/bullet.png); margin: 1em; padding: 0px 1em; text-align: justify;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Full Outer Join: In Full Outer Join, all the rows in all joined tables are included, whether they are matched or not.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;color: #384f83; font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; margin: 1em 0px 0px; padding: 0px; text-align: justify;&quot;&gt;
Self Join&lt;/h3&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
This is a particular case when one table joins to itself with one or two aliases to avoid confusion. A self join can be of any type, as long as the joined tables are the same. A self join is rather unique in that it involves a relationship with only one table. The common example is when company has a hierarchal reporting structure whereby one member of staff reports to another. Self Join can be Outer Join or Inner Join. (&lt;a href=&quot;http://blog.sqlauthority.com/2007/06/03/sql-server-2005-explanation-and-example-self-join/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot;&gt;Read more here&lt;/a&gt;)&lt;/div&gt;
&lt;h2 style=&quot;font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; letter-spacing: 1px; margin: 1em 0px 0px; padding: 0px; text-align: justify;&quot;&gt;
What are Primary Keys and Foreign Keys?&lt;/h2&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Primary keys are the unique identifiers for each row. They must contain unique values and cannot be null. Due to their importance in relational databases, Primary keys are the most fundamental aspect of all keys and constraints. A table can have only one primary key.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Foreign keys are a method of ensuring data integrity and manifestation of the relationship between tables.&lt;/div&gt;
&lt;h2 style=&quot;font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; letter-spacing: 1px; margin: 1em 0px 0px; padding: 0px; text-align: justify;&quot;&gt;
What is User-defined Functions? What are the types of User-defined Functions that can be created?&lt;/h2&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
User-defined Functions allow defining its own T-SQL functions that can accept zero or more parameters and return a single scalar data value or a table data type.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;Different Types of User-Defined Functions created are as follows:&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;Scalar User-defined Function&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
A scalar user-defined function returns one of the scalar data types. Text, ntext, image and timestamp data types are not supported. These are the type of user-defined functions that most developers are used to in other programming languages.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;Inline Table-Value User-defined Function&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
An Inline table-value user-defined function returns a table data type and is an exceptional alternative to a view as the user-defined function can pass parameters into a T-SQL select command and in essence provide us with a parameterized, non-updateable view of the underlying tables.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;Multi-Statement Table-Value User-defined Function&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
A multi-statement table-value user-defined function returns a table, and it is also an exceptional alternative to a view as the function can support multiple T-SQL statements to build the final result where the view is limited to a single SELECT statement. Also, the ability to pass parameters into a T-SQL select command or a group of them gives us the capability to in essence create a parameterized, non-updateable view of the data in the underlying tables. Within the create function command, you must define the table structure that is being returned. After creating this type of user-defined function, It can be used in the FROM clause of a T-SQL command unlike the behavior encountered while using a stored procedure which can also return record sets. (&lt;a href=&quot;http://blog.sqlauthority.com/2007/09/08/sql-server-udf-user-defined-function-get-number-of-days-in-month/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot;&gt;Read here for example&lt;/a&gt;)&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;a href=&quot;http://blog.sqlauthority.com/2011/07/01/sql-server-interview-questions-and-answers-frequently-asked-questions-complete-downloadable-list-day-0-of-31&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;List of all the Interview Questions and Answers Series blogs&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Reference:&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Pinal Dave (&lt;/strong&gt;&lt;a href=&quot;http://blog.sqlauthority.com/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;http://blog.SQLAuthority.com&lt;/strong&gt;&lt;/a&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/1923520271742426141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/05/sql-server-interview-questions-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1923520271742426141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1923520271742426141'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/05/sql-server-interview-questions-and.html' title='SQL SERVER – Interview Questions and Answers – Frequently Asked Questions – Day 4 of 31'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-1743863884130512542</id><published>2013-05-15T03:16:00.001-07:00</published><updated>2013-05-15T03:16:45.969-07:00</updated><title type='text'>SQLAuthority News – Sharding or No Sharding of Database – Working on my Weekend Project</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;posttitle&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 0px; padding: 0px;&quot;&gt;
&lt;div class=&quot;post-info&quot; style=&quot;background-image: url(http://s2.wp.com/wp-content/themes/pub/mistylook/img/underline1.jpg); background-position: 0% 100%; background-repeat: no-repeat no-repeat; color: #999999; font-size: 0.9em; line-height: 1.6em; padding: 0px 0px 12px;&quot;&gt;
May 7, 2013 by&amp;nbsp;&lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; style=&quot;color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 1em 0px; overflow: hidden; padding: 0px 1em 0px 0px;&quot;&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Recently I came across situation where database sharding was once again a suggested solution by architectures.&amp;nbsp;&lt;span class=&quot;GINGER_SOFATWARE_correct&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;Everytime&lt;/span&gt;&amp;nbsp;I hear the word sharding I remember my earlier article about&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://bit.ly/sql-nuodb&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;NuoDB&amp;nbsp;&lt;/a&gt;&lt;/strong&gt;on&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://blog.sqlauthority.com/2012/11/27/sql-server-shard-no-more-an-innovative-look-at-distributed-peer-to-peer-sql-database/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Shard No More – An Innovative Look at Distributed Peer-to-peer SQL Database&lt;/a&gt;&lt;/strong&gt;.&amp;nbsp;Sharding requires developers to think about things like rollbacks, constraints, and referential integrity across tables within their applications when these types of concerns are best handled by the database. It also makes other common operations such as joins, searches, and memory management very difficult.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;img alt=&quot;&quot; class=&quot;alignnone&quot; height=&quot;179&quot; src=&quot;http://www.pinaldave.com/bimg/nuodbshard2.jpg&quot; style=&quot;background-image: url(http://s2.wp.com/wp-content/themes/pub/mistylook/img/shadow.gif); background-position: 100% 100%; background-repeat: no-repeat no-repeat; border-left-color: rgb(238, 238, 238); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(238, 238, 238); border-top-width: 1px; height: auto; margin: 0px; max-width: 100%; padding: 4px 10px 10px 4px;&quot; width=&quot;500&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Each&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://go.nuodb.com/download-request-SQL-authority.html&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;NuoDB&lt;/a&gt;&lt;/strong&gt;&amp;nbsp;database consists of at least three or more processes that enable a single database to run across multiple hosts. These processes include a Broker, a Transaction Engine and a Storage Manager.&amp;nbsp; Brokers are responsible for connecting client applications to Transaction Engines and maintain a global view of the network to keep track of the multiple Transaction Engines available at any time. Transaction Engines are in-memory processes that client applications connect to for processing SQL transactions.&amp;nbsp;&lt;span class=&quot;GINGER_SOFATWARE_correct&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;Storage&lt;/span&gt;&amp;nbsp;Managers are responsible for persisting data to disk and serving up records to the Transaction Managers if they don’t exist in memory.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Here is my question to you all –&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;do you ever face a situation&amp;nbsp;of sharding of your database is required? When is sharding required not a good solution?&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
I have downloaded&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://bit.ly/sql-nuodb&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;NuoDB&lt;/a&gt;&amp;nbsp;&lt;/strong&gt;today and going to build a small application which I can play with to build a scenario where sharding is no longer required. Would you be interesting in joining me with this exercise? I would like to work along with you to build such a scenario.&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://bit.ly/sql-nuodb&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Download NuoDB&lt;/a&gt;&lt;/strong&gt;&amp;nbsp;and let us start building something interesting.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Reference:&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Pinal Dave (&lt;a href=&quot;http://blog.sqlauthority.com/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;http://blog.sqlauthority.com&lt;/a&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/1743863884130512542/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/05/sqlauthority-news-sharding-or-no.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1743863884130512542'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1743863884130512542'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/05/sqlauthority-news-sharding-or-no.html' title='SQLAuthority News – Sharding or No Sharding of Database – Working on my Weekend Project'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-3608108154132973723</id><published>2013-04-25T00:03:00.002-07:00</published><updated>2013-04-25T00:03:42.432-07:00</updated><title type='text'>Pessimistic Locking?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h5 class=&quot;uiStreamMessage userContentWrapper&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:1,&amp;quot;tn&amp;quot;:&amp;quot;K&amp;quot;}&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;span class=&quot;userContent&quot;&gt;Pessimistic
 Locking is when you lock the record for your exclusive use until you 
have finished with it. It has much better integrity than optimistic 
locking but requires you to be careful with your application design to 
avoid Deadlocks.&lt;br /&gt; (Read more here &lt;a href=&quot;http://bit.ly/sql-interview&quot; rel=&quot;nofollow nofollow&quot; target=&quot;_blank&quot;&gt;http://bit.ly/sql-interview&lt;/a&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h5&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/3608108154132973723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/04/pessimistic-locking.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/3608108154132973723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/3608108154132973723'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/04/pessimistic-locking.html' title='Pessimistic Locking?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-654465905993272922</id><published>2013-04-11T01:15:00.001-07:00</published><updated>2013-04-11T01:15:39.734-07:00</updated><title type='text'>Which are the Important Points to Note when Multilanguage Data is Stored in a Table?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;Which are the Important Points to Note when Multilanguage Data is Stored in a Table?&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;There are two things to keep in mind while storing unicode data. First, the column must be of unicode data type (nchar, nvarchar, ntext). Second, the value must be prefixed with N while insertion. For example,&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;INSERT INTO table (Hindi_col) values (N’hindi data’)&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;(Read more here&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://bit.ly/sql-interview&quot; rel=&quot;nofollow nofollow&quot; style=&quot;background-color: white; color: #3b5998; cursor: pointer; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot; target=&quot;_blank&quot;&gt;http://bit.ly/sql-interview&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/654465905993272922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/04/which-are-important-points-to-note-when.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/654465905993272922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/654465905993272922'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/04/which-are-important-points-to-note-when.html' title='Which are the Important Points to Note when Multilanguage Data is Stored in a Table?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-2144366218575239746</id><published>2013-04-03T03:35:00.002-07:00</published><updated>2013-04-03T03:35:25.031-07:00</updated><title type='text'>What is the Difference between GRANT and WITH GRANT while Giving Permissions to the User?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;In case of only GRANT, the username cannot grant the same permission to other users. On the other hand, with the option WITH GRANT, the username will be able to give the permission after receiving requests from other users. (Read more here&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://bit.ly/sql-interview&quot; rel=&quot;nofollow nofollow&quot; style=&quot;background-color: white; color: #3b5998; cursor: pointer; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;http://bit.ly/sql-interview&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/2144366218575239746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/04/what-is-difference-between-grant-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/2144366218575239746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/2144366218575239746'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/04/what-is-difference-between-grant-and.html' title='What is the Difference between GRANT and WITH GRANT while Giving Permissions to the User?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-2353126507174757404</id><published>2013-04-03T03:32:00.004-07:00</published><updated>2013-04-03T03:32:59.841-07:00</updated><title type='text'>Explain Few of the New Features of SQL Server 2008 Management Studio</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;SQL Server 2008 Microsoft has upgraded SSMS with many new features as well as added tons of new functionalities requested by DBAs for long time.&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;A few of the important new features are as follows:&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot; /&gt;&lt;span class=&quot;text_exposed_show&quot; style=&quot;background-color: white; color: #333333; display: inline; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;br /&gt;IntelliSense for Query Editing&lt;br /&gt;Multi Server Query&lt;br /&gt;Query Editor Regions&lt;br /&gt;Object Explorer Enhancements&lt;br /&gt;Activity Monitors&lt;br /&gt;&lt;br /&gt;(&lt;a href=&quot;http://bit.ly/sql-interview&quot; rel=&quot;nofollow nofollow&quot; style=&quot;color: #3b5998; cursor: pointer; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;http://bit.ly/sql-interview&lt;/a&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;text_exposed_show&quot; style=&quot;background-color: white; color: #333333; display: inline; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;text_exposed_show&quot; style=&quot;background-color: white; color: #333333; display: inline; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;text_exposed_show&quot; style=&quot;background-color: white; color: #333333; display: inline; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;text_exposed_show&quot; style=&quot;background-color: white; color: #333333; display: inline; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;text_exposed_show&quot; style=&quot;background-color: white; color: #333333; display: inline; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;text_exposed_show&quot; style=&quot;background-color: white; color: #333333; display: inline; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;text_exposed_show&quot; style=&quot;background-color: white; color: #333333; display: inline; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;Explain Few of the New Features of SQL Server 2008 Management Studio&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/2353126507174757404/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/04/explain-few-of-new-features-of-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/2353126507174757404'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/2353126507174757404'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/04/explain-few-of-new-features-of-sql.html' title='Explain Few of the New Features of SQL Server 2008 Management Studio'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-6287332680120624182</id><published>2013-03-22T01:44:00.001-07:00</published><updated>2013-03-22T01:44:14.905-07:00</updated><title type='text'>Create a SQL Login User in SQL Server 2008</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;This article will give a walkthrough on creating a SQL Login user.&amp;nbsp;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;b style=&quot;outline: none 0px;&quot;&gt;Step 1&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;/b&gt;Login to SQL Server 2008 instance using windows authentication&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;img alt=&quot;Image1.gif&quot; border=&quot;0&quot; height=&quot;310&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/create-a-sql-login-user-in-sql-server-2008/Images/Image1.gif&quot; style=&quot;border: none; outline: none 0px;&quot; width=&quot;416&quot; /&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;b style=&quot;outline: none 0px;&quot;&gt;Step 2&lt;/b&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;Right click on server instance name and select properties.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;img alt=&quot;Image2.gif&quot; border=&quot;0&quot; height=&quot;477&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/create-a-sql-login-user-in-sql-server-2008/Images/Image2.gif&quot; style=&quot;border: none; outline: none 0px;&quot; width=&quot;374&quot; /&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;b style=&quot;outline: none 0px;&quot;&gt;Step 3&lt;/b&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;Property window will be open. In that select the Security tab.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;img alt=&quot;Image3.gif&quot; border=&quot;0&quot; height=&quot;557&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/create-a-sql-login-user-in-sql-server-2008/Images/Image3.gif&quot; style=&quot;border: none; outline: none 0px;&quot; width=&quot;621&quot; /&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;In server authentication tab you can see your SQL Server in configured for&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;ol style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;li style=&quot;outline: none 0px;&quot;&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;Windows authentication mode&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;outline: none 0px;&quot;&gt;SQL Server and Windows Authentication mode&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;So if you want to enable SQL User login to SQL Server then select checked mixed mode here .&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;img alt=&quot;Image4.gif&quot; border=&quot;0&quot; height=&quot;101&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/create-a-sql-login-user-in-sql-server-2008/Images/Image4.gif&quot; style=&quot;border: none; outline: none 0px;&quot; width=&quot;473&quot; /&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;And then click ok. Now SQL Server is configured for mixed mode login.&amp;nbsp;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;b style=&quot;outline: none 0px;&quot;&gt;Step 4&lt;/b&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;Now to create SQL LOGIN, right click on Security tab and select New and then Login .&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;img alt=&quot;Image5.gif&quot; border=&quot;0&quot; height=&quot;147&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/create-a-sql-login-user-in-sql-server-2008/Images/Image5.gif&quot; style=&quot;border: none; outline: none 0px;&quot; width=&quot;355&quot; /&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;b style=&quot;outline: none 0px;&quot;&gt;Step 5&lt;/b&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;When you click on Login you will get the below window&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;img alt=&quot;Image6.gif&quot; border=&quot;0&quot; height=&quot;502&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/create-a-sql-login-user-in-sql-server-2008/Images/Image6.gif&quot; style=&quot;border: none; outline: none 0px;&quot; width=&quot;559&quot; /&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;Give the Login Name&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;img alt=&quot;Image7.gif&quot; border=&quot;0&quot; height=&quot;84&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/create-a-sql-login-user-in-sql-server-2008/Images/Image7.gif&quot; style=&quot;border: none; outline: none 0px;&quot; width=&quot;505&quot; /&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;Select SQL Server Authentication and provide your desired password&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;img alt=&quot;Image8.gif&quot; border=&quot;0&quot; height=&quot;146&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/create-a-sql-login-user-in-sql-server-2008/Images/Image8.gif&quot; style=&quot;border: none; outline: none 0px;&quot; width=&quot;463&quot; /&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;Disable Enforce password policy&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;img alt=&quot;Image9.gif&quot; border=&quot;0&quot; height=&quot;295&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/create-a-sql-login-user-in-sql-server-2008/Images/Image9.gif&quot; style=&quot;border: none; outline: none 0px;&quot; width=&quot;483&quot; /&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;Select default database&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;img alt=&quot;Image10.gif&quot; border=&quot;0&quot; height=&quot;140&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/create-a-sql-login-user-in-sql-server-2008/Images/Image10.gif&quot; style=&quot;border: none; outline: none 0px;&quot; width=&quot;505&quot; /&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;Leave default language and click OK to create a new SQL Server login&amp;nbsp;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;Now in object explorer you can see User1 login .&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &#39;segoe UI&#39;; font-size: small; outline: none 0px;&quot;&gt;
&lt;img alt=&quot;Image11.gif&quot; border=&quot;0&quot; height=&quot;388&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/create-a-sql-login-user-in-sql-server-2008/Images/Image11.gif&quot; style=&quot;border: none; outline: none 0px;&quot; width=&quot;278&quot; /&gt;&lt;span style=&quot;font-size: x-small; outline: none 0px;&quot;&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;&lt;br style=&quot;outline: none 0px;&quot; /&gt;Now at time of connecting to SQL Server login User1 can be used.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/6287332680120624182/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/03/create-sql-login-user-in-sql-server-2008.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/6287332680120624182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/6287332680120624182'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/03/create-sql-login-user-in-sql-server-2008.html' title='Create a SQL Login User in SQL Server 2008'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-1851141110739563476</id><published>2013-03-20T00:06:00.002-07:00</published><updated>2013-03-20T00:06:32.608-07:00</updated><title type='text'>SQL SERVER – Retrieve SQL Server Installation Date Time</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;posttitle&quot; sizcache06742680152938931=&quot;23 78 34&quot; sizset=&quot;false&quot;&gt;
&lt;div class=&quot;post-info&quot; sizcache06742680152938931=&quot;23 78 34&quot; sizset=&quot;false&quot;&gt;
July 5, 
2012 by &lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt; &lt;/div&gt;
&lt;div class=&quot;post-info&quot; sizcache06742680152938931=&quot;23 78 34&quot; sizset=&quot;false&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; sizcache06742680152938931=&quot;31 87 273&quot; sizset=&quot;false&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I have been asked this question a number of times 
and my answer always has been “Search online and you will find the answer.” 
Every single time someone follows my answer, he finds the accurate answer in 
just a few clicks. However, this question is getting very popular nowadays, so I 
decided to answer this question through a blog post.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I usually prefer creating my own T-SQL script but 
in today’s case, I have taken the script from the Web. I have seen this script 
in so many places that I do not know who the original creator is, so I’m not 
sure who should get credit for the script.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Question:&lt;/strong&gt; How do I retrieve SQL 
Server Installation date?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Answer:&lt;/strong&gt; Run the following query 
and it will give you the date of SQL Server Installation.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT &lt;/span&gt;create_date&lt;br /&gt;&lt;span style=&quot;color: blue;&quot;&gt;FROM 
&lt;/span&gt;&lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_026aa7b522c3767e524f37c36df82ab0dcb4bef3_sys:0&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_026aa7b522c3767e524f37c36df82ab0dcb4bef3_.:1&quot;&gt;.&lt;/span&gt;server_principals&lt;br /&gt;&lt;span style=&quot;color: blue;&quot;&gt;WHERE &lt;/span&gt;&lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_9e8a619cc3864b50f498687eb073f2d4645a7067_sid:0&quot;&gt;sid&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;= &lt;/span&gt;0x010100000000000512000000&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Question:&lt;/strong&gt; I have installed SQL 
Server Evaluation version. How do I know what is the expiry date for it?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Answer:&lt;/strong&gt; SQL Server evaluation 
period lasts for 180 days. The expiration date is always 180 days from the 
initial installation. The following query will give the expiration date of 
evaluation version:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;-- Evaluation Version Expire Date&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT &lt;/span&gt;create_date 
&lt;span style=&quot;color: blue;&quot;&gt;AS &lt;/span&gt;&lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_81b4a5ff7856ec20aa581bd3ccf9ef40a93cf938_InstallationDate:0&quot;&gt;InstallationDate&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_ea3dce9dddc639756b74c4225ab1e06e92469529_(:0&quot;&gt;(&lt;/span&gt;&lt;/span&gt;DD&lt;span style=&quot;color: grey;&quot;&gt;, &lt;/span&gt;180&lt;span style=&quot;color: grey;&quot;&gt;, &lt;/span&gt;create_date&lt;span style=&quot;color: grey;&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;AS &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;Expiry Date&#39;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;FROM 
&lt;/span&gt;&lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_026aa7b522c3767e524f37c36df82ab0dcb4bef3_sys:0&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_026aa7b522c3767e524f37c36df82ab0dcb4bef3_.:1&quot;&gt;.&lt;/span&gt;server_principals&lt;br /&gt;&lt;span style=&quot;color: blue;&quot;&gt;WHERE &lt;/span&gt;&lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_9e8a619cc3864b50f498687eb073f2d4645a7067_sid:0&quot;&gt;sid&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;= &lt;/span&gt;0x010100000000000512000000&lt;br /&gt;GO&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I believe there is a way to do this using &lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_240b02c4463c635298845e7bf7c3b2f9fb9161d2_registry:0&quot;&gt;registry&lt;/span&gt;, but I have not explored it personally. Now as 
what I’ve said earlier, there are many different blog posts on this subject. Let 
me list a few which I really enjoyed &lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_ca026591b95b50ea471efacea0089db29a1dc985_to read:0&quot;&gt;to read&lt;/span&gt; as they shared a few more insights about this 
subject:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div sizcache06742680152938931=&quot;23 78 35&quot; sizset=&quot;false&quot; style=&quot;text-align: justify;&quot;&gt;
&lt;a href=&quot;http://www.mssqlgirl.com/retrieving-sql-server-2012-evaluation-period-expiry-date.html&quot; target=&quot;_blank&quot;&gt;Retrieving SQL Server 2012 Evaluation Period Expiry Date&lt;/a&gt;&lt;/div&gt;
&lt;div sizcache06742680152938931=&quot;23 78 36&quot; sizset=&quot;false&quot; style=&quot;text-align: justify;&quot;&gt;
&lt;a href=&quot;http://thesqldude.com/2011/08/09/how-to-find-the-installation-date-for-an-evaluation-edition-of-sql-server/&quot; target=&quot;_blank&quot;&gt;How to find the Installation Date for an Evaluation Edition of SQL 
Server&lt;/a&gt;&lt;/div&gt;
&lt;div sizcache06742680152938931=&quot;23 78 37&quot; sizset=&quot;false&quot; style=&quot;text-align: justify;&quot;&gt;
Reference:&amp;nbsp;&lt;strong sizcache06742680152938931=&quot;23 78 37&quot; sizset=&quot;false&quot;&gt;Pinal Dave (&lt;a href=&quot;http://blog.sqlauthority.com/&quot; target=&quot;_blank&quot;&gt;http://blog.sqlauthority.com&lt;/a&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/1851141110739563476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/03/sql-server-retrieve-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1851141110739563476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1851141110739563476'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/03/sql-server-retrieve-sql-server.html' title='SQL SERVER – Retrieve SQL Server Installation Date Time'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-6978832162096577856</id><published>2013-03-20T00:03:00.003-07:00</published><updated>2013-03-20T00:03:49.088-07:00</updated><title type='text'>What is Optimistic Locking ?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Optimistic Locking 
is a strategy where you read a record, take note of a version number and check 
that the version hasn’t changed before you write the record back. If the record 
is dirty (i.e. different version to yours), then you abort the transaction and 
the user can re-start it.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: large;&quot;&gt;(Read more here &lt;/span&gt;&lt;a href=&quot;http://www.facebook.com/l.php?u=http%3A%2F%2Fbit.ly%2Fsql-interview&amp;amp;h=BAQE-yf7QAQEIO13GiXqJuWzUygX_P9rIWjF8fshyLXkDBg&amp;amp;s=1&quot; rel=&quot;nofollow nofollow&quot; style=&quot;font-size: x-large;&quot; target=&quot;_blank&quot;&gt;http://bit.ly/sql-interview&lt;/a&gt;&lt;span style=&quot;font-size: large;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/6978832162096577856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/03/what-is-optimistic-locking.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/6978832162096577856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/6978832162096577856'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/03/what-is-optimistic-locking.html' title='What is Optimistic Locking ?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-8346784961223448141</id><published>2013-02-26T03:43:00.004-08:00</published><updated>2013-02-26T03:43:33.890-08:00</updated><title type='text'>How to backup and restore database on Microsoft SQL Server 2005</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h2&gt;
Introduction&lt;/h2&gt;
&lt;div class=&quot;post-content&quot;&gt;
This
 post will give you a brief introduction of SQL Server backup. As we 
know, SQL Server backup software is springing up nowadays. Take &lt;a href=&quot;http://www.todo-backup.com/landing/sql-server-backup-software.htm&quot;&gt;EaseUS Todo Backup Advanced Server&lt;/a&gt;
 as an example, it’s an all-in-one SQL server backup software for MS SQL
 Server 2000/2005/2008, exchange server and server 2000/2003/2008, and 
provides proven database backup solution for Server administrators.&lt;br /&gt;
&lt;span id=&quot;more-66&quot;&gt;&lt;/span&gt;&lt;br /&gt;
But
 in the example below, I will show a step-by-step database backup from 
SQL Server 2005 and restore the database to another SQL Server 2005 
Express Edition using Microsoft SQL Server Management Studio.&lt;br /&gt;
&lt;h3&gt;
Step-by-step&lt;/h3&gt;
&lt;h4&gt;
Backup a database.&lt;/h4&gt;
Now I will backup AdventureWorks database on BKKSQL2005 which runs Microsoft SQL Server 2005 to a file.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Connect to source server. Open Microsoft SQL Server Management Studio and connect to BKKSQL2005.&lt;/li&gt;
&lt;li&gt;Right-click on the AdventureWorks database. Select Tasks -&amp;gt; Backup…&lt;br /&gt; &lt;img alt=&quot;Backup a SQL Server database&quot; height=&quot;533&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/1.png&quot; title=&quot;Backup a SQL Server database&quot; width=&quot;454&quot; /&gt;&lt;/li&gt;
&lt;li&gt;On
 Back Up Database window, you can configure about backup information. If
 you’re not familiar these configurations, you can leave default values.
 Here are some short descriptions.&lt;ol&gt;
&lt;li&gt;Database – a database that you want to backup.&lt;/li&gt;
&lt;li&gt;Backup
 type – you can select 2 options: Full and Differential. If this is the 
first time you backup the database, you must select Full.&lt;/li&gt;
&lt;li&gt;Name – Name of this backup, you can name anything as you want.&lt;/li&gt;
&lt;li&gt;Destination
 – the file that will be backup to. You can leave as default. Default 
will backup to “C:\Program Files\Microsoft SQL 
Server\MSSQL.1\MSSQL\Backup”.&lt;/li&gt;
&lt;li&gt;Click OK to proceed backup.&lt;/li&gt;
&lt;/ol&gt;
&lt;img alt=&quot;Select source and destination to backup&quot; height=&quot;494&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/2.png&quot; title=&quot;Select source and destination to backup&quot; width=&quot;550&quot; /&gt;&lt;/li&gt;
&lt;li&gt;Wait for a while and you’ll see a pop-up message when backup is finished.&lt;br /&gt; &lt;img alt=&quot;Backup success pop-up message&quot; height=&quot;112&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/3.png&quot; title=&quot;Backup success pop-up message&quot; width=&quot;550&quot; /&gt;&lt;/li&gt;
&lt;li&gt;Browse
 to the destination, you’ll see a backup file (.bak format) which you 
can copy to other server for restore in the next step. Default backup 
directory is “C:\Program Files\Microsoft SQL 
Server\MSSQL.1\MSSQL\Backup”.&lt;br /&gt; &lt;img alt=&quot;The backup file from SQL Server 2005 Server&quot; height=&quot;140&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/4.png&quot; title=&quot;The backup file from SQL Server 2005 Server&quot; width=&quot;402&quot; /&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;
Restore the database.&lt;/h4&gt;
Next,
 I will restore the AdventureWorks database from a file that I’ve 
created above to BK01BIZ001 which runs Microsoft SQL Server Express 
Edition.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Copy the backup file from source server to destination server. I’ve copied into the same directory as source server.&lt;br /&gt; &lt;img alt=&quot;The backup file&quot; height=&quot;146&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/8.png&quot; title=&quot;The backup file&quot; width=&quot;403&quot; /&gt;&lt;/li&gt;
&lt;li&gt;Connect to destination server. Open Microsoft SQL Server Management Studio Express and connect to BK01BIZ001.&lt;/li&gt;
&lt;li&gt;Right-click on Databases. Select Restore Database…&lt;br /&gt; &lt;img alt=&quot;Restore the database&quot; height=&quot;361&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/5.png&quot; title=&quot;Restore the database&quot; width=&quot;345&quot; /&gt;&lt;/li&gt;
&lt;li&gt;Restore Database window appears. On Source for restore, select From device and click [...] buttton to browse file.&lt;img alt=&quot;Select source device&quot; height=&quot;494&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/6.png&quot; title=&quot;Select source device&quot; width=&quot;550&quot; /&gt;&lt;/li&gt;
&lt;li&gt;On Specify Backup, ensure that Backup media is “File” and click Add.&lt;br /&gt; &lt;img alt=&quot;Select the backup media to restore&quot; height=&quot;353&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/7.png&quot; title=&quot;Select the backup media to restore&quot; width=&quot;492&quot; /&gt;&lt;/li&gt;
&lt;li&gt;On
 Locate Backup File, select the backup file. This is the backup file 
that was created in Backup a database section and was copied to this 
server. Click OK. OK.&lt;br /&gt; &lt;img alt=&quot;Select the backup file to restore&quot; height=&quot;604&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/9.png&quot; title=&quot;Select the backup file to restore&quot; width=&quot;427&quot; /&gt;&lt;/li&gt;
&lt;li&gt;Back to Restore Database window.&lt;ol&gt;
&lt;li&gt;On Destination for restore, select “AdventureWorks”.&lt;br /&gt; &lt;em&gt;Note: If you haven’t added the backup file on Source before (step 4-6), you won’t see the database name on Destination&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;On Source for restore, check the box in front of the backup name (in Restore column).&lt;/li&gt;
&lt;li&gt;Click OK.&lt;/li&gt;
&lt;/ol&gt;
&lt;img alt=&quot;Select a destination database to restore&quot; height=&quot;494&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/10.png&quot; title=&quot;Select a destination database to restore&quot; width=&quot;550&quot; /&gt;&lt;/li&gt;
&lt;li&gt;Wait until restore finish and there’ll be a pop-up message notify.&lt;br /&gt; &lt;img alt=&quot;Restore success pop-up message&quot; height=&quot;112&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/11.png&quot; title=&quot;Restore success pop-up message&quot; width=&quot;550&quot; /&gt;&lt;/li&gt;
&lt;li&gt;Now you’ll see the restored database on the destination SQL Server.&lt;br /&gt; &lt;img alt=&quot;The restored database on SQL Server 2005&quot; height=&quot;216&quot; src=&quot;http://www.linglom.com/images/howto/sqlServer/backup/12.png&quot; title=&quot;The restored database on SQL Server 2005&quot; width=&quot;312&quot; /&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/8346784961223448141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/how-to-backup-and-restore-database-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/8346784961223448141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/8346784961223448141'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/how-to-backup-and-restore-database-on.html' title='How to backup and restore database on Microsoft SQL Server 2005'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-7221615515518731057</id><published>2013-02-26T02:57:00.001-08:00</published><updated>2013-02-26T02:57:45.623-08:00</updated><title type='text'>SQL Authority News – Download SQL Server Data Type Conversion Chart</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;posttitle&quot;&gt;
&lt;h2&gt;
&lt;br /&gt;&lt;/h2&gt;
&lt;div class=&quot;post-info&quot;&gt;
December 9, 2012 by &lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;GRnoSuggestion GRcorrect&quot;&gt;Datatypes&lt;/span&gt; are very important concepts of 
SQL Server and there are quite often need to convert them from one &lt;span class=&quot;GRnoSuggestion GRcorrect&quot;&gt;datatypes&lt;/span&gt; to another &lt;span class=&quot;GRcorrect&quot;&gt;datatype&lt;/span&gt;. I have seen that &lt;span class=&quot;GRcorrect&quot;&gt;deveoper&lt;/span&gt; &lt;span class=&quot;GRcorrect&quot;&gt;often get&lt;/span&gt; confused 
when they have to convert the &lt;span class=&quot;GRcorrect&quot;&gt;datatype&lt;/span&gt;. There are 
two important &lt;span class=&quot;GRcorrect&quot;&gt;concept&lt;/span&gt; when it is about &lt;span class=&quot;GRnoSuggestion GRcorrect&quot;&gt;datatype&lt;/span&gt; conversion.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Implicit Conversion:&lt;/strong&gt; Implicit 
conversions are those conversions that occur without specifying either the CAST 
or CONVERT function.&lt;br /&gt;&lt;strong&gt;Explicit Conversions:&lt;/strong&gt;&amp;nbsp;Explicit 
conversions are those conversions that require the CAST or CONVERT function to 
be specified.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
What it means is that if you are trying to 
convert value from datetime2 to time or from tinyint to int, SQL Server will 
automatically convert (implicit conversation) for you. However, if you are 
attempting to convert timestamp to smalldatetime or datetime to int you will 
need to explicitely convert them using either CAST or CONVERT function as well 
appropriate parameters.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Let us see a quick example of Implict Conversion 
and Explict Conversion.&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
Implicit&amp;nbsp;Conversion:&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;img alt=&quot;&quot; class=&quot;alignnone&quot; height=&quot;239&quot; src=&quot;http://www.pinaldave.com/bimg/conversion1.jpg&quot; width=&quot;388&quot; /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
Explicit Conversion:&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;img alt=&quot;&quot; class=&quot;alignnone&quot; height=&quot;233&quot; src=&quot;http://www.pinaldave.com/bimg/conversion2.jpg&quot; width=&quot;505&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
You can see from above example that how we need 
both of the types of conversion in different situation. There are so many 
different datatypes and it is humanly impossible to know which datatype require 
implicit and which require explicit conversion. Additionally there are cases 
when the conversion is not possible as well.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Microsoft have published a chart where the grid 
displays various conversion possibilities as well a quick guide.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;&lt;a href=&quot;http://www.microsoft.com/en-us/download/details.aspx?id=35834&quot; target=&quot;_blank&quot;&gt;Download SQL Server Data Type Conversion Chart&lt;/a&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Reference:&amp;nbsp;&lt;strong&gt;Pinal Dave (&lt;a href=&quot;http://blog.sqlauthority.com/&quot; target=&quot;_blank&quot;&gt;http://blog.sqlauthority.com&lt;/a&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/7221615515518731057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-authority-news-download-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/7221615515518731057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/7221615515518731057'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-authority-news-download-sql-server.html' title='SQL Authority News – Download SQL Server Data Type Conversion Chart'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-2654835097823502269</id><published>2013-02-22T03:32:00.000-08:00</published><updated>2013-02-22T03:32:14.766-08:00</updated><title type='text'>SQL SERVER – Delete Duplicate Records – Rows</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;posttitle&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 0px; padding: 0px;&quot;&gt;
&lt;h2 style=&quot;font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; letter-spacing: 1px; margin: 1em 0px 0px; padding: 0px;&quot;&gt;
&lt;br /&gt;&lt;/h2&gt;
&lt;div class=&quot;post-info&quot; style=&quot;background-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/underline1.jpg); background-position: 0% 100%; background-repeat: no-repeat no-repeat; color: #999999; font-size: 0.9em; line-height: 1.6em; padding: 0px 0px 12px;&quot;&gt;
March 1, 2007 by&amp;nbsp;&lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; style=&quot;color: #384f83; margin: 0px; padding: 0px; text-decoration: initial;&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 1em 0px; overflow: hidden; padding: 0px 1em 0px 0px;&quot;&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Following code is useful to delete duplicate records. The table must have identity column, which will be used to identify the duplicate records. Table in&lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_daf0a08e744d819a1168c6d90c6f5cb1ce3710a1_example:0&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;example&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;GRcorrect&quot; id=&quot;GRmark_daf0a08e744d819a1168c6d90c6f5cb1ce3710a1_is has:1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;is has&lt;/span&gt;&amp;nbsp;ID as Identity Column and Columns which have duplicate data are DuplicateColumn1, DuplicateColumn2 and DuplicateColumn3.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;DELETE&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;FROM MyTable&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;WHERE ID NOT IN&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;(&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;SELECT MAX(ID)&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;FROM MyTable&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3)&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Watch the view to see the above concept in action:&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;span class=&quot;embed-youtube&quot; style=&quot;display: block; margin: 0px; padding: 0px; text-align: center;&quot;&gt;&lt;iframe class=&quot;youtube-player&quot; frameborder=&quot;0&quot; height=&quot;312&quot; src=&quot;http://www.youtube.com/embed/ioDJ0xVOHDY?version=3&amp;amp;rel=1&amp;amp;fs=1&amp;amp;showsearch=0&amp;amp;showinfo=1&amp;amp;iv_load_policy=1&amp;amp;wmode=transparent&quot; style=&quot;margin: 0px; max-width: 100%; padding: 0px;&quot; type=&quot;text/html&quot; width=&quot;500&quot;&gt;&lt;/iframe&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Reference :&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Pinal Dave (&lt;/strong&gt;&lt;a href=&quot;http://blog.sqlauthority.com/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: initial;&quot; target=&quot;_blank&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;http://blog.SQLAuthority.com&lt;/strong&gt;&lt;/a&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/2654835097823502269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-server-delete-duplicate-records-rows.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/2654835097823502269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/2654835097823502269'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-server-delete-duplicate-records-rows.html' title='SQL SERVER – Delete Duplicate Records – Rows'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/ioDJ0xVOHDY/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-7830352411411933761</id><published>2013-02-22T02:17:00.001-08:00</published><updated>2013-02-22T02:17:35.131-08:00</updated><title type='text'>SQL SERVER – 2008 – Introduction to Table-Valued Parameters with Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;posttitle&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 0px; padding: 0px;&quot;&gt;
&lt;h2 style=&quot;font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; letter-spacing: 1px; margin: 1em 0px 0px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: #999999; font-family: verdana, tahoma, arial, sans-serif; font-size: 0.9em; line-height: 1.6em;&quot;&gt;August 31, 2008 by&lt;/span&gt;&lt;span style=&quot;color: #999999; font-family: verdana, tahoma, arial, sans-serif; font-size: 0.9em; line-height: 1.6em;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; style=&quot;color: #384f83; font-family: verdana, tahoma, arial, sans-serif; font-size: 0.9em; line-height: 1.6em; margin: 0px; padding: 0px; text-decoration: initial;&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 1em 0px; overflow: hidden; padding: 0px 1em 0px 0px;&quot;&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Table-Valued Parameters&lt;/strong&gt;&lt;/em&gt;&amp;nbsp;is a new feature introduced in SQL SERVER 2008. In earlier versions of SQL SERVER it is not possible to pass a table variable in stored procedure as a parameter, but now in SQL SERVER 2008 we can use Table-Valued Parameter to send multiple rows of data to a stored procedure or a function without creating a temporary table or passing so many parameters.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Table-valued parameters are declared using user-defined table types. To use a Table Valued Parameters we need follow steps shown below:&lt;/div&gt;
&lt;ol style=&quot;margin: 2em; padding: 0px 2em; text-align: justify;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Create a table type and define the table structure&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Declare a stored procedure that has a parameter of table type.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Declare a table type variable and reference the table type.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Using the INSERT statement and occupy the variable.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;We can now pass the variable to the procedure.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
For Example,&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Let’s create a Department Table and pass the table variable to insert data using procedure. In our example we will create Department table and afterward we will query it and see that all the content of table value parameter is inserted into it.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Department:&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;CREATE&amp;nbsp;TABLE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;Department&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;DepartmentID&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INT&amp;nbsp;PRIMARY&amp;nbsp;KEY&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;DepartmentName&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;)&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;1. Create a TABLE TYPE and define the table structure:&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;CREATE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TYPE&amp;nbsp;DeptType&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;AS&amp;nbsp;TABLE&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;DeptId&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;DeptName&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;);&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;img alt=&quot;&quot; height=&quot;208&quot; src=&quot;http://www.pinaldave.com/bimg/TVP/1_DeptType.gif&quot; style=&quot;background-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/shadow.gif); background-position: 100% 100%; background-repeat: no-repeat no-repeat; border-left-color: rgb(238, 238, 238); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(238, 238, 238); border-top-width: 1px; height: auto; margin: 0px; max-width: 100%; padding: 4px 10px 10px 4px;&quot; width=&quot;405&quot; /&gt;&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;2. Declare a STORED PROCEDURE that has a parameter of table type:&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;CREATE&amp;nbsp;PROCEDURE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;InsertDepartment&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@InsertDept_TVP&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;DeptType&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;READONLY&lt;/span&gt;&lt;/code&gt;&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;AS&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;INSERT&amp;nbsp;INTO&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;Department&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;DepartmentID&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;DepartmentName&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;*&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@InsertDept_TVP&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Important points &amp;nbsp;to remember :&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
-&amp;nbsp; Table-valued parameters must be passed as READONLY parameters to SQL routines. You cannot perform DML operations like UPDATE, DELETE, or INSERT on a table-valued parameter in the body of a routine.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
-&amp;nbsp; You cannot use a table-valued parameter as target of a SELECT INTO or INSERT EXEC statement. A table-valued parameter can be in the FROM clause of SELECT INTO or in the INSERT EXEC string or stored-procedure.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;img alt=&quot;&quot; height=&quot;247&quot; src=&quot;http://www.pinaldave.com/bimg/TVP/2_Procedure.gif&quot; style=&quot;background-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/shadow.gif); background-position: 100% 100%; background-repeat: no-repeat no-repeat; border-left-color: rgb(238, 238, 238); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(238, 238, 238); border-top-width: 1px; height: auto; margin: 0px; max-width: 100%; padding: 4px 10px 10px 4px;&quot; width=&quot;500&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;3. Declare a table type variable and reference the table type.&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;DECLARE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@DepartmentTVP&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;AS&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;DeptType&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;4. Using the INSERT statement and occupy the variable.&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INSERT&amp;nbsp;INTO&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@DepartmentTVP&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;DeptId&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;DeptName&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VALUES&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;&#39;Accounts&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;),&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;&#39;Purchase&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;),&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;&#39;Software&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;),&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;&#39;Stores&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;),&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;&#39;Maarketing&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;5. We can now pass the variable to the procedure and Execute.&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;EXEC&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;InsertDepartment&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@DepartmentTVP&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;/strong&gt;&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;&lt;img alt=&quot;&quot; height=&quot;350&quot; src=&quot;http://www.pinaldave.com/bimg/TVP/3_Execute.gif&quot; style=&quot;background-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/shadow.gif); background-position: 100% 100%; background-repeat: no-repeat no-repeat; border-left-color: rgb(238, 238, 238); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(238, 238, 238); border-top-width: 1px; height: auto; margin: 0px; max-width: 100%; padding: 4px 10px 10px 4px;&quot; width=&quot;429&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Let’s see if the Data are inserted in the Department Table&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;img alt=&quot;&quot; height=&quot;348&quot; src=&quot;http://www.pinaldave.com/bimg/TVP/4_Select.gif&quot; style=&quot;background-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/shadow.gif); background-position: 100% 100%; background-repeat: no-repeat no-repeat; border-left-color: rgb(238, 238, 238); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(238, 238, 238); border-top-width: 1px; height: auto; margin: 0px; max-width: 100%; padding: 4px 10px 10px 4px;&quot; width=&quot;342&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Conclusion:&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Table-Valued Parameters is a new parameter type in SQL SERVER 2008 that provides efficient way of passing the table type variable than using the temporary table or passing so many parameters. It helps in using complex business logic in single routine. They reduce Round Trips to the server making the performance better.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Reference :&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Pinal Dave (&lt;/strong&gt;&lt;a href=&quot;http://blog.sqlauthority.com/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: initial;&quot; target=&quot;_blank&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;http://blog.SQLAuthority.com&lt;/strong&gt;&lt;/a&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/7830352411411933761/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-server-2008-introduction-to-table.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/7830352411411933761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/7830352411411933761'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-server-2008-introduction-to-table.html' title='SQL SERVER – 2008 – Introduction to Table-Valued Parameters with Example'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-6028340704600642720</id><published>2013-02-20T02:22:00.000-08:00</published><updated>2013-02-20T02:22:02.241-08:00</updated><title type='text'>What is CHECK Constraint?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot;&gt;A CHECK constraint is used to limit the values that can be&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot;&gt;placed in a column. The check constraints are used to&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot;&gt;enforce domain integrity.&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot; /&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot;&gt;(Read more here&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://bit.ly/sql-interview&quot; rel=&quot;nofollow nofollow&quot; style=&quot;background-color: white; color: #3b5998; cursor: pointer; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px; text-decoration: initial;&quot; target=&quot;_blank&quot;&gt;http://bit.ly/sql-interview&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;lucida grande&#39;, tahoma, verdana, arial, sans-serif; line-height: 17px;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/6028340704600642720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/what-is-check-constraint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/6028340704600642720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/6028340704600642720'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/what-is-check-constraint.html' title='What is CHECK Constraint?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-1978503913189495071</id><published>2013-02-12T22:23:00.001-08:00</published><updated>2013-02-12T22:23:08.820-08:00</updated><title type='text'>SQL SERVER – Stored Procedure Optimization Tips – Best Practices</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;posttitle&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 0px; padding: 0px;&quot;&gt;
&lt;div class=&quot;post-info&quot; style=&quot;background-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/underline1.jpg); background-position: 0% 100%; background-repeat: no-repeat no-repeat; color: #999999; font-size: 0.9em; line-height: 1.6em; padding: 0px 0px 12px;&quot;&gt;
February 16, 2010 by&amp;nbsp;&lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; style=&quot;color: #384f83; margin: 0px; padding: 0px; text-decoration: initial;&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 1em 0px; overflow: hidden; padding: 0px 1em 0px 0px;&quot;&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px;&quot;&gt;
We will go over how to optimize Stored Procedure with making simple changes in the code. Please note there are many more other tips, which we will cover in future articles.&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;ul style=&quot;list-style-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/bullet.png); margin: 1em; padding: 0px 1em; text-align: justify;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Include SET NOCOUNT ON statement:&lt;/strong&gt;&amp;nbsp;With every SELECT and DML statement, the SQL server returns a message that indicates the number of affected rows by that statement. This information is mostly helpful in debugging the code, but it is useless after that. By setting SET NOCOUNT ON, we can disable the feature of returning this extra information. For stored procedures that contain several statements or contain Transact-SQL loops, setting SET NOCOUNT to ON can provide a significant performance boost because network traffic is greatly reduced.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px 0px 0px 60px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;CREATE&amp;nbsp;PROC&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;dbo.ProcName&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;AS&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;SET&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;NOCOUNT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--Procedure&amp;nbsp;code&amp;nbsp;here&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;column1&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;dbo.TblTable1&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Reset&amp;nbsp;SET&amp;nbsp;NOCOUNT&amp;nbsp;to&amp;nbsp;OFF&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SET&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;NOCOUNT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;OFF&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;ul style=&quot;list-style-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/bullet.png); margin: 1em; padding: 0px 1em; text-align: justify;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Use schema name with object name:&lt;/strong&gt;&amp;nbsp;The object name is qualified if used with schema name. Schema name should be used with the stored procedure name and with all objects referenced inside the stored procedure. This help in directly finding the complied plan instead of searching the objects in other possible schema before finally deciding to use a cached plan, if available. This process of searching and deciding a schema for an object leads to COMPILE lock on stored procedure and decreases the stored procedure’s performance. Therefore, always refer the objects with qualified name in the stored procedure like&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px 0px 0px 60px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;*&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;dbo.MyTable&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Preferred&amp;nbsp;method&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;--&amp;nbsp;Instead&amp;nbsp;of&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;*&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;MyTable&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Avoid&amp;nbsp;this&amp;nbsp;method&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;--And&amp;nbsp;finally&amp;nbsp;call&amp;nbsp;the&amp;nbsp;stored&amp;nbsp;procedure&amp;nbsp;with&amp;nbsp;qualified&amp;nbsp;name&amp;nbsp;like:&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;EXEC&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;dbo.MyProc&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Preferred&amp;nbsp;method&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;--Instead&amp;nbsp;of&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;EXEC&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;MyProc&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Avoid&amp;nbsp;this&amp;nbsp;method&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;ul style=&quot;list-style-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/bullet.png); margin: 1em; padding: 0px 1em; text-align: justify;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Do not use the prefix “sp_” in the stored procedure name&lt;/strong&gt;: If a stored procedure name begins with “SP_,” then SQL server first searches in the master database and then in the current session database. Searching in the master database causes extra overhead and even a wrong result if another stored procedure with the same name is found in master database.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;list-style-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/bullet.png); margin: 1em; padding: 0px 1em; text-align: justify;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Use IF EXISTS (SELECT 1) instead of (SELECT *):&lt;/strong&gt;&amp;nbsp;To check the existence of a record in another table, we uses the IF EXISTS clause. The IF EXISTS clause returns True if any value is returned from an internal statement, either a single value “1” or all columns of a record or complete recordset. The output of the internal statement is not used. Hence, to minimize the data for processing and network transferring, we should use “1” in the SELECT clause of an internal statement, as shown below:&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px 0px 0px 60px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;IF&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;EXISTS&amp;nbsp;(&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;1&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;sysobjects&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;WHERE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;name&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;&#39;MyTable&#39;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;AND&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;type&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;&#39;U&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;ul style=&quot;list-style-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/bullet.png); margin: 1em; padding: 0px 1em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Use the sp_executesql stored procedure instead of the EXECUTE statement.&lt;/strong&gt;&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;The sp_executesql stored procedure supports parameters. So, using the sp_executesql stored procedure instead of the EXECUTE statement improve the re-usability of your code. The execution plan of a dynamic statement can be reused only if each and every character, including case, space, comments and parameter, is same for two statements. For example, if we execute the below batch:&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px 0px 0px 60px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;DECLARE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@Query&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;DECLARE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@Age&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INT&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;SET&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@Age&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SET&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@Query&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;&#39;SELECT&amp;nbsp;*&amp;nbsp;FROM&amp;nbsp;dbo.tblPerson&amp;nbsp;WHERE&amp;nbsp;Age&amp;nbsp;=&amp;nbsp;&#39;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: magenta; margin: 0px; padding: 0px;&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@Age&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;EXEC&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@Query&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
If we again execute the above batch using different @Age value, then the execution plan for SELECT statement created for @Age =25 would not be reused. However, if we write the above batch as given below,&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px 0px 0px 60px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;DECLARE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@Query&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SET&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@Query&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;N&#39;SELECT&amp;nbsp;*&amp;nbsp;FROM&amp;nbsp;dbo.tblPerson&amp;nbsp;WHERE&amp;nbsp;Age&amp;nbsp;=&amp;nbsp;@Age&#39;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;EXECUTE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkred; margin: 0px; padding: 0px;&quot;&gt;sp_executesql&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@Query&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;N&#39;@Age&amp;nbsp;int&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@Age&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;25&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
the compiled plan of this SELECT statement will be reused for different value of @Age parameter. The reuse of the existing complied plan will result in improved performance.&lt;/div&gt;
&lt;ul style=&quot;list-style-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/bullet.png); margin: 1em; padding: 0px 1em; text-align: justify;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Try to avoid using SQL Server cursors whenever possible:&lt;/strong&gt;&amp;nbsp;Cursor uses a lot of resources for overhead processing to maintain current record position in a recordset and this decreases the performance. If we need to process records one-by-one in a loop, then we should use the WHILE clause. Wherever possible, we should replace the cursor-based approach with SET-based approach. Because the SQL Server engine is designed and optimized to perform SET-based operation very fast. Again, please note cursor is also a kind of WHILE Loop.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Keep the Transaction as short as possible:&lt;/strong&gt;&amp;nbsp;The length of transaction affects blocking and deadlocking. Exclusive lock is not released until the end of transaction. In higher isolation level, the shared locks are also aged with transaction. Therefore, lengthy transaction means locks for longer time and locks for longer time turns into blocking. In some cases, blocking also converts into deadlocks. So, for faster execution and less blocking, the transaction should be kept as short as possible.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Use TRY-Catch for error handling&lt;/strong&gt;: Prior to SQL server 2005 version code for error handling, there was a big portion of actual code because an error check statement was written after every t-sql statement. More code always consumes more resources and time. In SQL Server 2005, a new simple way is introduced for the same purpose. The syntax is as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px 0px 0px 60px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;BEGIN&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TRY&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--Your&amp;nbsp;t-sql&amp;nbsp;code&amp;nbsp;goes&amp;nbsp;here&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;END&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TRY&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;BEGIN&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;CATCH&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--Your&amp;nbsp;error&amp;nbsp;handling&amp;nbsp;code&amp;nbsp;goes&amp;nbsp;here&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;END&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;CATCH&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Reference:&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Pinal Dave (&lt;/strong&gt;&lt;a href=&quot;http://blog.sqlauthority.com/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: initial;&quot; target=&quot;_blank&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;http://blog.SQLAuthority.com&lt;/strong&gt;&lt;/a&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/1978503913189495071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-server-stored-procedure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1978503913189495071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1978503913189495071'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-server-stored-procedure.html' title='SQL SERVER – Stored Procedure Optimization Tips – Best Practices'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-90352258110880930</id><published>2013-02-12T22:20:00.001-08:00</published><updated>2013-02-12T22:20:26.889-08:00</updated><title type='text'>SQL SERVER – Stored Procedure and Transactions</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;posttitle&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 0px; padding: 0px;&quot;&gt;
&lt;div class=&quot;post-info&quot; style=&quot;background-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/underline1.jpg); background-position: 0% 100%; background-repeat: no-repeat no-repeat; color: #999999; font-size: 0.9em; line-height: 1.6em; padding: 0px 0px 12px;&quot;&gt;
June 2, 2010 by&amp;nbsp;&lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; style=&quot;color: #384f83; margin: 0px; padding: 0px; text-decoration: initial;&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 1em 0px; overflow: hidden; padding: 0px 1em 0px 0px;&quot;&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
I just overheard the following statement – “&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;I do not use Transactions in SQL as I use Stored Procedure&lt;/em&gt;&lt;/strong&gt;“.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
I just realized that there are so many misconceptions about this subject. Transactions has nothing to do with Stored Procedures. Let me demonstrate that with a simple example.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;USE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;tempdb&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;GO&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Create&amp;nbsp;3&amp;nbsp;Test&amp;nbsp;Tables&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;CREATE&amp;nbsp;TABLE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE1&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;ID&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;CREATE&amp;nbsp;TABLE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE2&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;ID&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;CREATE&amp;nbsp;TABLE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE3&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;ID&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Create&amp;nbsp;SP&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;CREATE&amp;nbsp;PROCEDURE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TestSP&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;AS&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;INSERT&amp;nbsp;INTO&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE1&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VALUES&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INSERT&amp;nbsp;INTO&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE2&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VALUES&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;&#39;a&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INSERT&amp;nbsp;INTO&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE3&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VALUES&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Execute&amp;nbsp;SP&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;--&amp;nbsp;SP&amp;nbsp;will&amp;nbsp;error&amp;nbsp;out&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;EXEC&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TestSP&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;GO&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Check&amp;nbsp;the&amp;nbsp;Values&amp;nbsp;in&amp;nbsp;Table&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE1&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE2&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE3&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Now, the main point is: If Stored Procedure is transactional then, it should roll back complete transactions when it encounters any errors. Well, that does not happen in this case, which proves that Stored Procedure does not only provide just the transactional feature to a batch of T-SQL.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Let’s see the result very quickly.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;img alt=&quot;&quot; class=&quot;alignnone&quot; height=&quot;232&quot; src=&quot;http://www.pinaldave.com/bimg/SPTran1.jpg&quot; style=&quot;background-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/shadow.gif); background-position: 100% 100%; background-repeat: no-repeat no-repeat; border-left-color: rgb(238, 238, 238); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(238, 238, 238); border-top-width: 1px; height: auto; margin: 0px; max-width: 100%; padding: 4px 10px 10px 4px;&quot; width=&quot;500&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
It is very clear that there were entries in table1 which are not shown in the subsequent tables. If SP was transactional in terms of T-SQL Query Batches, there would be no entries in any of the tables. If you want to use Transactions with Stored Procedure, wrap the code around with BEGIN TRAN and COMMIT TRAN.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
The example is as following.&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;CREATE&amp;nbsp;PROCEDURE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TestSPTran&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;AS&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;BEGIN&amp;nbsp;TRAN&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;INSERT&amp;nbsp;INTO&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE1&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VALUES&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INSERT&amp;nbsp;INTO&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE2&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VALUES&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red; margin: 0px; padding: 0px;&quot;&gt;&#39;b&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INSERT&amp;nbsp;INTO&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE3&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VALUES&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;33&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;COMMIT&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Execute&amp;nbsp;SP&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;EXEC&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TestSPTran&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;GO&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Check&amp;nbsp;the&amp;nbsp;Values&amp;nbsp;in&amp;nbsp;Tables&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE1&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE2&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;TABLE3&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: green; margin: 0px; padding: 0px;&quot;&gt;--&amp;nbsp;Clean&amp;nbsp;up&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;DROP&amp;nbsp;TABLE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;Table1&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;DROP&amp;nbsp;TABLE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;Table2&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;DROP&amp;nbsp;TABLE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;Table3&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
In this case, there will be no entries in any part of the table. What is your opinion about this blog post? Please leave your comments about it here.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Reference:&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Pinal Dave (&lt;/strong&gt;&lt;a href=&quot;http://blog.sqlauthority.com/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: initial;&quot; target=&quot;_blank&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;http://blog.SQLAuthority.com&lt;/strong&gt;&lt;/a&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/90352258110880930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-server-stored-procedure-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/90352258110880930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/90352258110880930'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-server-stored-procedure-and.html' title='SQL SERVER – Stored Procedure and Transactions'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-9032820757964997252</id><published>2013-02-12T03:10:00.001-08:00</published><updated>2013-02-12T03:10:28.866-08:00</updated><title type='text'>SQL SERVER – Effect of SET NOCOUNT on @@ROWCOUNT</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;posttitle&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 0px; padding: 0px;&quot;&gt;
&lt;h2 style=&quot;font-family: Georgia, Verdana, Arial, serif; font-size: 1.4em; font-weight: normal; letter-spacing: 1px; margin: 1em 0px 0px; padding: 0px;&quot;&gt;
&lt;br /&gt;&lt;/h2&gt;
&lt;div class=&quot;post-info&quot; style=&quot;background-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/underline1.jpg); background-position: 0% 100%; background-repeat: no-repeat no-repeat; color: #999999; font-size: 0.9em; line-height: 1.6em; padding: 0px 0px 12px;&quot;&gt;
December 2, 2011 by&amp;nbsp;&lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; style=&quot;color: #384f83; margin: 0px; padding: 0px; text-decoration: initial;&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; style=&quot;background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin: 1em 0px; overflow: hidden; padding: 0px 1em 0px 0px;&quot;&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Today I had very interesting experience when I was presenting on SQL Server. While I was presenting the session when I ran query SQL Server Management Studio returned message like (8 row(s) affected) and (2 row(s) affected) etc. After a while at one point, I started to prove usage of @@ROWCOUNT function.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
As I was in hurry, I quickly wrote very similar to following example on my screen. (The real query is much complected, but for the purpose of this post I am simplifing it here.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;code style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;DECLARE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@table&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;TABLE&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;col1&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;IDENTITY&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;),&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;col2&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;INSERT INTO&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@table&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;col2&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;VALUES&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;2932&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;142&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;352&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;),(&lt;/span&gt;&lt;span style=&quot;color: black; margin: 0px; padding: 0px;&quot;&gt;342&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SET NOCOUNT ON&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; margin: 0px; padding: 0px;&quot;&gt;*&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@table&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #434343; margin: 0px; padding: 0px;&quot;&gt;@@rowcount&lt;/span&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;SET NOCOUNT OFF&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Before I execute the script nearly 10 hands went up in audience. This was bit surprise to me as I do not know why they all got alerted. I assumed that there should be something wrong with either project, screen or my display. I quickly asked to one person what is wrong, he pointed out that I will not get right results in @@ROWCOUNT as I am using immediately before SET NOCOUNT ON. When I asked the reason they told me that because any statement when ran right before @@ROWCOUNT resets its value.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Let us stop here for a second –&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;do YOU think same way as well?&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
If yes, run above code and check your result in following image.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
&lt;img alt=&quot;&quot; class=&quot;alignnone&quot; height=&quot;287&quot; src=&quot;http://www.pinaldave.com/bimg/rowcountwithnocount.jpg&quot; style=&quot;background-image: url(http://s0.wp.com/wp-content/themes/pub/mistylook/img/shadow.gif); background-position: 100% 100%; background-repeat: no-repeat no-repeat; border-left-color: rgb(238, 238, 238); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(238, 238, 238); border-top-width: 1px; height: auto; margin: 0px; max-width: 100%; padding: 4px 10px 10px 4px;&quot; width=&quot;328&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
If you believed the same I guess we learned something new. I have no problem confessing I learn something new every single time, I learn something new. However, I was bit surprised with this common myth of SET NOCOUNT ON and @@ROWCOUNT.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Are there any other common myths – if yes, do share here with your comment. If I think it is interesting, I will publish it this blog with due credit and you can win my new&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://blog.sqlauthority.com/sql-server-books/sql-server-interview-questions-and-answers-for-all-database-developers-and-developers-administrators/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: initial;&quot; target=&quot;_blank&quot;&gt;SQL Server Interview Questions and Answers&lt;/a&gt;&lt;/strong&gt;&amp;nbsp;book as well.&lt;/div&gt;
&lt;div style=&quot;line-height: 1.6em; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;&quot;&gt;
Reference:&amp;nbsp;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Pinal Dave (&lt;/strong&gt;&lt;a href=&quot;http://blog.sqlauthority.com/&quot; style=&quot;border-bottom-color: rgb(56, 79, 131); border-bottom-style: dashed; border-bottom-width: 1px; color: #384f83; margin: 0px; padding: 0px; text-decoration: initial;&quot; target=&quot;_blank&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;http://blog.SQLAuthority.com&lt;/strong&gt;&lt;/a&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/9032820757964997252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-server-effect-of-set-nocount-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/9032820757964997252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/9032820757964997252'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/02/sql-server-effect-of-set-nocount-on.html' title='SQL SERVER – Effect of SET NOCOUNT on @@ROWCOUNT'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-1836885141104136286</id><published>2013-01-24T04:31:00.000-08:00</published><updated>2013-01-24T04:31:09.157-08:00</updated><title type='text'>How to Install SQL Server 2008 - A Step by Step Guide</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;A Step by Step guide to installing SQL Server 2008 simply and successfully with no prior knowledge&lt;/b&gt; 
&lt;br /&gt;

Developers and system administrators will find this installation guide 
useful, as will seasoned DBAs. It will teach you the basics required for
 a typical, problem-free installation of SQL Server 2008, allowing you 
to add other components later if you wish.
&lt;br /&gt;
 
&lt;b&gt;Remember to install the .Net Framework 3.5&lt;/b&gt;

Before you start the installation, you’ll need to install the .Net 3.5 
Framework. This comes pre-installed on Windows 2008 Server, but for 
earlier versions of Windows, you’ll need to install it first. This is a 
straightforward pre-requisite and is usually included as part of the SQL
 Server 2008 installation. However, if you don’t know how to do this, or
 for some reason you need to download it, check out the guide 
    &lt;a class=&quot;BlueToOrange&quot; href=&quot;http://www.sqlserverclub.com/pdfs/how-to-install-the-dotnet-framework3.5-for-sql-server-2008.pdf&quot; target=&quot;_blank&quot;&gt;Installing .Net Framework 3.5 for SQL Server 2008&lt;/a&gt;.
&lt;br /&gt;


Once this Framework in installed you can commence the installation of SQL Server 2008.
&lt;br /&gt;

&lt;b&gt;STEP 1 : Copy the installation files&lt;/b&gt;

First off I’d recommend you copy the entire directory structure from the
 SQL Server 2008 installation disc to the C: drive of the machine you 
are going to install it on. 
&lt;br /&gt;


Although this means you need to grab a cup of coffee whilst it’s copying, this has three advantages:
&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;It makes the installation process much faster than running it from CD/DVD once it gets started.&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;It allows you to easily add or remove components later, without having to hunt around for the CD/DVD.&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;If your media is damaged and a file won’t copy, you get to find out now, rather than halfway through the installation.&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
Here’s what my system looks like after the copy:

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen01.gif&quot; /&gt;
&lt;br /&gt;

&lt;b&gt;STEP 2 : Setup.exe&lt;/b&gt;

Double click on the setup.exe file.&lt;br /&gt;
After a few seconds a dialog box appears:
&lt;br /&gt;
 
&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen02.gif&quot; /&gt;

This will disappear from the screen and then the main installation page appears:
&lt;br /&gt;
    
&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen03.gif&quot; /&gt;

&lt;b&gt;STEP 3 : SQL Server Installation Center&lt;/b&gt;
&lt;br /&gt;

Click on the Installation hyperlink on the left hand side of the screen:

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen04.gif&quot; /&gt;
&lt;br /&gt;

&lt;b&gt;STEP 4 : SQL Server Installation Center&lt;/b&gt;

Click on the &lt;b&gt;&quot;New Server stand-alone installation&quot;&lt;/b&gt; link on the right side of the screen:
&lt;br /&gt;

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen05.gif&quot; /&gt;

The following dialog appears on the screen whilst the install program prepares for installation:
&lt;br /&gt;

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen06.gif&quot; /&gt;

After a minute or so (the timing will vary according to your system), the following screen appears:
&lt;br /&gt;

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen07.gif&quot; /&gt;

&lt;b&gt;STEP 5 (optional) :&lt;/b&gt;
&lt;br /&gt;

If any checks have failed, click on the Show details button or &quot;View 
detailed report link&quot; to find out the cause, correct it, then click on 
the Re-run button to perform the checks again.

&lt;b&gt;STEP 6 : Product key&lt;/b&gt;
&lt;br /&gt;

If all checks have passed, click on the OK button. After a few moments, 
the option to select the edition and to enter the license key (or 
“product key”) will appear. Note that the product key box may already be
 populated, depending on which edition you have. Don’t enter the product
 key we’ve shown here, it won’t work on your system!:

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen08.gif&quot; /&gt;
&lt;br /&gt;

&lt;b&gt;STEP 7 : License Terms&lt;/b&gt;

Enter the product key into the box, or choose the free edition if you&#39;re
 evaluating SQL Server 2008, and click on the Next button:
&lt;br /&gt;

Click in the &lt;b&gt;&quot;I accept the license terms&quot;&lt;/b&gt; check box, then click on the &lt;b&gt;Next&lt;/b&gt; button again.

&lt;b&gt;STEP 8 : Setup Support Files&lt;/b&gt;
&lt;br /&gt;

The following screen appears; click on the Install button:

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen09.gif&quot; /&gt;
&lt;br /&gt;

The following screen will appear whilst Windows Installer prepares itself for the installation. This will take a short while:

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen10.gif&quot; /&gt;
&lt;br /&gt;


After 30 seconds or so the dialog appears again:
&lt;br /&gt;

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen11.gif&quot; /&gt;

&lt;b&gt;STEP 9 : Setup Support Rules&lt;/b&gt;
&lt;br /&gt;

If all is well, the following screen appears:

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen12.gif&quot; /&gt;
&lt;br /&gt;
    
Click on the &lt;b&gt;Next&lt;/b&gt; button again.    

&lt;b&gt;STEP 10 : Feature Selection&lt;/b&gt;
&lt;br /&gt;
    
&lt;b&gt;Select the features you want to install.&lt;/b&gt;&lt;br /&gt;
At a minimum, the following are useful (I&#39;d argue essential), but what you need will depend on your needs:

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen13.gif&quot; /&gt;
&lt;br /&gt;
    
Click on the &lt;b&gt;Next&lt;/b&gt; button.
 
&lt;b&gt;STEP 11 : Instance Configuration&lt;/b&gt;
&lt;br /&gt;

After a short while the following screen appears:

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen14.gif&quot; /&gt;
&lt;br /&gt;

For most installations, keep the default settings.&lt;br /&gt;
Click on the &lt;b&gt;Next&lt;/b&gt; button.
 
&lt;b&gt;STEP 12 : Disk Space Requirements&lt;/b&gt;
&lt;br /&gt;

This screen just tells you if you have sufficient disk space on the 
drive you’re installing to, and what’s going to be installed where.

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen15.gif&quot; /&gt;
&lt;br /&gt;

Click on &lt;b&gt;Next&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;b&gt;STEP 13 : Server Configuration&lt;/b&gt;
&lt;br /&gt;

This step allows you to set up the service accounts that will be used to
 run SQL Server. If you have created Windows NT or Active Directory 
accounts for use with services, use these.  

If not, then just to get the installation up and working, use the 
built-in Network Service account for all three services listed (this 
account does not require a password).
&lt;br /&gt;

This allows SQL Server to start up after installation. However, it can 
be easily changed later to another account through the Services applet 
(Control Panel -&amp;gt; Administrator Tools -&amp;gt; Services):

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen16.gif&quot; /&gt;
&lt;br /&gt;

In addition, remember to change the &lt;b&gt;Startup Type&lt;/b&gt; to &lt;b&gt;Automatic&lt;/b&gt;,
 for all three services. This automatically starts the SQL Server 
database engine, SQL Agent and SQL Browser services when the server is 
re-booted.

The first service runs the SQL Server database engines executable 
process. The other two services allow scheduled jobs to run after 
installation (and after a re-boot), and allow the SQL Server to be found
 by clients on the network.
&lt;br /&gt;

Do not worry about changing the collation tab, unless there is a 
specific requirement for anything other than the default collation 
sequence.
Finally, click on &lt;b&gt;Next&lt;/b&gt;.
 
&lt;b&gt;STEP 14 : Database Engine Configuration – Account Provision&lt;/b&gt;
&lt;br /&gt;

This screen allows you to set up database engine security.

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen17.gif&quot; /&gt;
&lt;br /&gt;

Change the &lt;b&gt;Authentication Mode&lt;/b&gt; to &lt;b&gt;Mixed Mode&lt;/b&gt; unless you are &lt;b&gt;certain&lt;/b&gt; you only need Windows-only authentication.
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Many third party applications rely on SQL Server logins to 
operate correctly, so if you are setting up a server for a third party 
application, rather than one developed in-house, enabling Mixed Mode 
authentication is a good idea.&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
If you pick Mixed Mode security, you must also enter a password for the sysadmin account (sa).  

Enter and confirm a secure password for the sa account and keep it 
somewhere safe. Do not give it to any one you do not want to have access
 to the SQL Server.
&lt;br /&gt;

Note that you MUST also provide a Windows NT account on the local 
machine as a SQL Server administrator. If you do not want Windows system
 administrators to be able walk up to the box and login to SQL Server, 
create a new, local, dummy Windows user and add this account instead. 
Otherwise, add in the local administrator account, or your own Windows 
account on the domain in which the SQL Server will reside.

&lt;b&gt;STEP 15 : Database Engine Configuration – Data Directories&lt;/b&gt;
&lt;br /&gt;

Click on the &lt;b&gt;Data Directories&lt;/b&gt; tab.

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen18.gif&quot; /&gt;
&lt;br /&gt;

Change the directories to specify which drives in your system will be used for the various types of database files.

Generally it’s advisable to put the User database directory and User log
 directory on separate physical drives for performance, but it will 
depend on how Windows has been configured and how many disk drives you 
have available.
&lt;br /&gt;

If you are installing on a single drive laptop or desktop, then simply specify:&lt;br /&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 200px;&quot;&gt;&lt;b&gt;Data root directory&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;C:\Program Files\Microsoft SQL Server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 200px;&quot;&gt;&lt;b&gt;User database directory&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;C:\Data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 200px;&quot;&gt;&lt;b&gt;User log directory&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;C:\Logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 200px;&quot;&gt;&lt;b&gt;Temp DB directory&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;C:\TempDB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 200px;&quot;&gt;&lt;b&gt;Temp Log directory&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;C:\TempDB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 200px;&quot;&gt;&lt;b&gt;Backup directory&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;C:\Backups&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Do not click on the &lt;b&gt;FILESTREAM&lt;/b&gt; tab unless you know you need to 
change these options, as it is not generally required for most 
installations, but can easily be changed by using sp_configure 
&#39;filestream_access_level&#39;, &#39;&#39;after SQL Server has been installed. Click on &lt;b&gt;Next&lt;/b&gt;.
&lt;br /&gt;

&lt;b&gt;STEP 16 : Error Usage Reporting&lt;/b&gt;

This screen simply asks if you want to send error information to 
Microsoft and can safely be skipped if you do not want to share any 
information.
&lt;br /&gt;


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen19.gif&quot; /&gt;
&lt;br /&gt;

Click boxes if you want to help Microsoft help you.&lt;br /&gt;
Click on &lt;b&gt;Next&lt;/b&gt; again…
 
&lt;b&gt;STEP 16 : Installation Rules&lt;/b&gt;
&lt;br /&gt;

This screen simply checks if there are any processes or other 
installations running which will stop the installation of SQL Server 
2008.

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen20.gif&quot; /&gt;
&lt;br /&gt;


Click on &lt;b&gt;Next&lt;/b&gt; again – you’re almost ready to install:
&lt;br /&gt;

&lt;b&gt;STEP 17 : Ready to Install&lt;/b&gt;

This screen summarises what you are about to install and gives you a 
last chance to cancel or change anything that’s wrongly configured:
&lt;br /&gt;

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen21.gif&quot; /&gt;

Check that what’s being installed is what you want and then click on &lt;b&gt;Install&lt;/b&gt; when you’re sure you want to start the installation process:
&lt;br /&gt;


&lt;b&gt;Installation Progress&lt;/b&gt;

SQL Server 2008 will now install. How long it takes depends on the speed
 of your machine, what load it’s under, the installation media (CD is 
slower) and what you’ve chosen to install.
&lt;br /&gt;


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen22.gif&quot; /&gt;

&lt;b&gt;…More Installation Progress&lt;/b&gt;
&lt;br /&gt;


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen23.gif&quot; /&gt;
&lt;br /&gt;


&lt;b&gt;... and Finally&lt;/b&gt;&lt;br /&gt;
Finally, the installation will complete:


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen24.gif&quot; /&gt;
&lt;br /&gt;

...and the following dialog box will appear:

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen25.gif&quot; /&gt;
&lt;br /&gt;


&lt;b&gt;Click on OK, the machine will NOT reboot.&lt;/b&gt;&lt;br /&gt;
The following will appear:

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen26.gif&quot; /&gt;
&lt;br /&gt;


…followed by: 

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen27.gif&quot; /&gt;
&lt;br /&gt;


&lt;b&gt;Click on the Next button again...&lt;/b&gt;


&lt;b&gt;STEP 18 : Installation Complete&lt;/b&gt;
&lt;br /&gt;

The following screen appears:


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen28.gif&quot; /&gt;
&lt;br /&gt;


It may be worth clicking on the installation log at the top of the 
screen to check everything’s gone as expected. Not that this is MUCH 
smaller than the usual SQL Server installation log files of old.

Finally, &lt;b&gt;click on the Close button&lt;/b&gt;. The following dialog will appear:
&lt;br /&gt;


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen29.gif&quot; /&gt;


&lt;b&gt;Click on OK – your server will NOT re-boot at this point.&lt;/b&gt;
&lt;br /&gt;


The dialog box will disappear and you will be returned to the Installation Center:


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen30.gif&quot; /&gt;
&lt;br /&gt;


&lt;b&gt;Click on the Close button&lt;/b&gt; (the “x”) in the top right of the screen.&lt;br /&gt;
Finally, manually reboot your machine to complete the SQL Server 2008 installation.

&lt;b&gt;Top Tips :&lt;/b&gt;
&lt;br /&gt;


&lt;b&gt;How to check that SQL Server 2008 has installed correctly&lt;/b&gt;

Here are a short number of post-installation checks which are useful to 
perform after re-booting your new SQL Server. You don’t have to run 
these, and there are other ways to check, but they are very useful for 
non-DBAs to be sure that the installation is basically sound and a 
connection can be made to the new SQL Server before handing it over to 
someone else.
&lt;br /&gt;


&lt;b&gt;Check 1: Has the SQL Server Service Started?&lt;/b&gt;

Check SQL Server 2008 has started.
&lt;br /&gt;


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen31.gif&quot; /&gt;


&lt;b&gt;Check 2: Does Management Studio Work?&lt;/b&gt;
&lt;br /&gt;


Check Management Studio works by firing it up.


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen32.gif&quot; /&gt;
&lt;br /&gt;


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen33.gif&quot; /&gt;


&lt;b&gt;Click on NO&lt;/b&gt; when you see this dialog box:
&lt;br /&gt;


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen34.gif&quot; /&gt;


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen35.gif&quot; /&gt;
&lt;br /&gt;


&lt;b&gt;Check 3: Can you run a basic query against the new SQL Server?&lt;/b&gt;


Check SQL Server works by running a simple query from Management Studio:
&lt;br /&gt;
            

&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen36.gif&quot; /&gt;


Enter the query shown below and hit F5 to run it:
&lt;br /&gt;


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen37.gif&quot; /&gt;


&lt;b&gt;Check 4: Is SQL Server Agent Running?&lt;/b&gt;
&lt;br /&gt;

Check SQL Server Agent is running for scheduled jobs. There should be a 
green arrow next to the SQL Server Agent database symbol (it’s small, 
you might have to look hard):


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen38.gif&quot; /&gt;
&lt;br /&gt;



&lt;b&gt;Check 5: Can SQL Server be seen from the Network?&lt;/b&gt;

Check that the new SQL Server can be seen from another SQL Server on the same domain by running isql –L (or osql –L): 
&lt;br /&gt;


If you can’t see the new SQL Server in this list, check that the SQL 
Server Browser service is started on the machine where you have just 
installed SQL Server.

 
&lt;b&gt;Check 6: Has the TCP/IP network protocol library been enabled on the server?&lt;/b&gt;
&lt;br /&gt;

If the browser service is started but you still cannot connect to the server, click on &lt;b&gt;Start -&amp;gt;Programs -&amp;gt; SQL Server 2008 -&amp;gt; SQL Server Configuration Manager&lt;/b&gt; (on the server where SQL Server’s just been installed)


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen39.gif&quot; /&gt;
&lt;br /&gt;


The SQL Server Configuration Manager window opens.&lt;br /&gt;
Click on the &lt;b&gt;SQL Server Network Configuration&lt;/b&gt; node and expand it.

In the example below, we have MSSQLSERVER (a base instance of SQL Server), and SQLEXPRESS showing as installed.&lt;br /&gt;
If in doubt, click on &lt;b&gt;Protocols for MSSQLSERVER&lt;/b&gt;.
&lt;br /&gt;


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen40.gif&quot; /&gt;


In the above screenshot, the TCP/IP network protocol library is 
disabled. We need to enable it in order that remote servers can talk to 
the newly installed SQL Server.
&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;b&gt;A word of explanation :&lt;/b&gt; In most installations, Named Pipes 
can be ignored, unless there is a requirement for it. In virtually all 
environments, VIA can also be ignored as this protocol requires a 
special network card. Shared memory is the “local” protocol that SQL 
Server uses when talking to a client application on the same server as 
itself, for example when SQL Server Management Studio connects to it. It
 is usually best to leave this enabled.&lt;/li&gt;
&lt;/ul&gt;
You will need the TCP/IP protocol enabled if you need to connect to your
 new SQL Server from a remote client or another server via TCP/IP, which
 is what most networks use.
&lt;br /&gt;

If it shows as &lt;b&gt;DISABLED&lt;/b&gt; (above), &lt;b&gt;double click on the TCP/IP protocol line&lt;/b&gt;, and the following window will appear:


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen41.gif&quot; /&gt;
&lt;br /&gt;


&lt;b&gt;Ensure&lt;/b&gt; that &lt;b&gt;Enabled is set to Yes&lt;/b&gt;, and click on OK.&lt;br /&gt;
The following warning will appear:


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen42.gif&quot; /&gt;
&lt;br /&gt;


Click on OK, and you will be returned to the Configuration Manager window, where TCP/IP will now be shown as enabled:


&lt;img src=&quot;http://www.sqlserverclub.com/images/articles/how-to-install-sql-server-2008/screen43.gif&quot; /&gt;
&lt;br /&gt;


Go back to the Services applet, and re-start the MSSQLSERVER service so 
that the TCP/IP protocol can be used to connect to your new SQL Server.

Then try to connect to it again from a remote machine.
&lt;br /&gt;

If you have experienced problems with the previous connectivity tests, 
you should now be able to repeat at least some of them successfully.
    &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/1836885141104136286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/01/how-to-install-sql-server-2008-step-by.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1836885141104136286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1836885141104136286'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/01/how-to-install-sql-server-2008-step-by.html' title='How to Install SQL Server 2008 - A Step by Step Guide'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-1135761042596977741</id><published>2013-01-20T22:46:00.003-08:00</published><updated>2013-01-20T22:46:50.490-08:00</updated><title type='text'>SQL SERVER – Fix: Error: 10920 Cannot drop user-defined function. It is being used as a resource governor classifier</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;posttitle&quot;&gt;
&lt;h2&gt;
&amp;nbsp;&lt;/h2&gt;
&lt;div class=&quot;post-info&quot;&gt;
June 5, 2012 by &lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; sizcache019642244324812286=&quot;1 2 0&quot; sizset=&quot;false&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
If you have not read my&amp;nbsp;&lt;strong&gt;&lt;a href=&quot;http://blog.sqlauthority.com/2012/06/04/sql-server-simple-example-to-configure-resource-governor-introduction-to-resource-governor/&quot; target=&quot;_blank&quot;&gt;SQL SERVER – Simple Example to Configure Resource Governor – Introduction to Resource Governor&lt;/a&gt;&lt;/strong&gt;&amp;nbsp;yesterday’s detailed primer on Resource Governor, I suggest you go ahead and read it before continuing this article. After reading the article the very first email I received was as follows:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;em&gt;“Pinal,&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;em&gt;I configured resource governor on my development server and it worked fine with &lt;span style=&quot;white-space: nowrap;&quot;&gt;tests I ran&lt;/span&gt;. After doing some tests, I decided to remove the resource governor and as a first step I disabled it however, I was not able to drop the classification function during the process of the clean up. It was continuously giving me following error.&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;em&gt;&lt;span style=&quot;color: red;&quot;&gt;Msg 10920, Level 16, State 1, Line 1&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;span style=&quot;color: red;&quot;&gt;Cannot drop user-defined function myudfname. It is being used as a resource governor classifier.&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;em&gt;Would you please give me solution?”&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The original email was really this short and there is no other information. I am glad he has done experiments on development server and not on the production server. Production server must not be the playground of the experiments. I think I have covered the answer of this error in &lt;strong&gt;&lt;a href=&quot;http://blog.sqlauthority.com/2012/06/04/sql-server-simple-example-to-configure-resource-governor-introduction-to-resource-governor/&quot; target=&quot;_blank&quot;&gt;an earlier blog post&lt;/a&gt;&lt;/strong&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
If the user disables the Resource Governor it is still not possible to drop the function because it can be enabled again and when enabled it can still use the same function. Here is the simple resolution of the how one can drop the classifier function (do this only if you are not going to use the function).&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The reason the &lt;span style=&quot;white-space: nowrap;&quot;&gt;classifier&amp;nbsp;&lt;/span&gt;function can’t be dropped because it is associated with resource governor. Create a new classified function for your resource governor or just assign NULL as described in the following T-SQL Script and you will be able to drop the function without error.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;ALTER &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RESOURCE GOVERNOR &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;WITH &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;CLASSIFIER_FUNCTION &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;NULL)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;ALTER &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RESOURCE GOVERNOR DISABLE&lt;br /&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;DROP FUNCTION &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;dbo.UDFClassifier&lt;br /&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I am glad that user asked me question instead of doing something radically different, which can leave the server in the unusable state. I am aware of this only method to avoid this error. Is there any better way to achieve the same?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Reference:&amp;nbsp;&lt;strong&gt;Pinal Dave (&lt;a href=&quot;http://blog.sqlauthority.com/&quot; target=&quot;_blank&quot;&gt;http://blog.sqlauthority.com&lt;/a&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/1135761042596977741/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/01/sql-server-fix-error-10920-cannot-drop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1135761042596977741'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/1135761042596977741'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/01/sql-server-fix-error-10920-cannot-drop.html' title='SQL SERVER – Fix: Error: 10920 Cannot drop user-defined function. It is being used as a resource governor classifier'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-7758664866356058146</id><published>2013-01-20T22:43:00.002-08:00</published><updated>2013-01-20T22:43:49.181-08:00</updated><title type='text'>SQL SERVER – Simple Example to Configure Resource Governor – Introduction to Resource Governor</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;posttitle&quot;&gt;
&lt;div class=&quot;post-info&quot;&gt;
June 4, 2012 by &lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; sizcache03235772288508794=&quot;1 2 0&quot; sizset=&quot;false&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Let us jump right away with question and answer mode.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;What is resource governor?&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Resource Governor is a feature which can manage SQL Server Workload and System Resource Consumption. We can limit the amount of CPU and memory consumption by limiting /governing /throttling on the SQL Server.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Why is resource governor required?&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
If there are different workloads running on SQL Server and each of the workload needs different resources or when workloads are competing for resources with each other and affecting the performance of the whole server resource governor is a very important task.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;What will be the real world example of need of resource governor?&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Here are two simple scenarios where the resource governor can be very useful.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Scenario 1:&lt;/strong&gt; A server which is running OLTP workload and various resource intensive reports on the same server. The ideal situation is where there are two servers which are data synced with each other and one server runs OLTP transactions and the second server runs all the resource intensive reports. However, not everybody has the luxury to set up this kind of environment. In case of the situation where reports and OLTP transactions are running on the same server, limiting the resources to the reporting workload it can be ensured that OTLP’s critical transaction is not throttled.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Scenario 2:&lt;/strong&gt; There are two DBAs in one organization. One DBA A runs critical queries for business and another DBA B is doing maintenance of the database. At any point in time the DBA A’s work should not be affected but at the same time DBA B should be allowed to work as well. The ideal situation is that when DBA B starts working he get some resources but he can’t get more than defined resources.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Does SQL Server have any default resource governor component?&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Yes, SQL Server have two by default created resource governor component.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
1)&amp;nbsp;Internal –This is used by database engine exclusives and user have no control.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
2) Default – This is used by all the workloads which are not assigned to any other group.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
What are the major components of the resource governor?&lt;/div&gt;
&lt;ul style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;Resource Pools&lt;/li&gt;
&lt;li&gt;Workload Groups&lt;/li&gt;
&lt;li&gt;Classification&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In simple words here is what the process of resource governor is.&lt;/div&gt;
&lt;ul style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;Create resource pool&lt;/li&gt;
&lt;li&gt;Create a workload group&lt;/li&gt;
&lt;li&gt;Create classification function based on the criteria specified&lt;/li&gt;
&lt;li&gt;Enable Resource Governor with classification function&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Let me further explain you the same with graphical image.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;img alt=&quot;&quot; class=&quot;alignnone&quot; height=&quot;376&quot; src=&quot;http://www.pinaldave.com/bimg/ResourceGovernor.jpg&quot; width=&quot;500&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Is it possible to configure resource governor with T-SQL?&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Yes, here is the code for it with explanation in between.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Step 0:&lt;/strong&gt; Here we are assuming that there are separate login accounts for Reporting server and OLTP server.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;/*-----------------------------------------------&lt;br /&gt;Step 0: (Optional and for Demo Purpose)&lt;br /&gt;Create Two User Logins&lt;br /&gt;1) ReportUser, 2) PrimaryUser&lt;br /&gt;Use ReportUser login for Reports workload&lt;br /&gt;Use PrimaryUser login for OLTP workload&lt;br /&gt;-----------------------------------------------*/&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Step 1:&lt;/strong&gt; Creating Resource Pool&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
We are creating two resource pools. 1) Report Server and 2) Primary OLTP Server. We are giving only a few resources&amp;nbsp;to the Report Server Pool as described in the scenario 1 the other server is mission critical and not the report server.&lt;br /&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;-----------------------------------------------&lt;br /&gt;-- Step 1: Create Resource Pool&lt;br /&gt;-----------------------------------------------&lt;br /&gt;-- Creating Resource Pool for Report Server&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;CREATE &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RESOURCE POOL ReportServerPool&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;( &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MIN_CPU_PERCENT&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MAX_CPU_PERCENT&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MIN_MEMORY_PERCENT&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MAX_MEMORY_PERCENT&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;-- Creating Resource Pool for OLTP Primary Server&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;CREATE &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RESOURCE POOL PrimaryServerPool&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;( &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MIN_CPU_PERCENT&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MAX_CPU_PERCENT&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MIN_MEMORY_PERCENT&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MAX_MEMORY_PERCENT&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Step 2:&lt;/strong&gt; Creating Workload Group&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
We are creating two workloads each mapping to each of the resource pool which we have just created.&lt;br /&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;-----------------------------------------------&lt;br /&gt;-- Step 2: Create Workload Group&lt;br /&gt;-----------------------------------------------&lt;br /&gt;-- Creating Workload Group for Report Server&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;CREATE &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;WORKLOAD &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;GROUP &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ReportServerGroup&lt;br /&gt;USING ReportServerPool &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;-- Creating Workload Group for OLTP Primary Server&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;CREATE &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;WORKLOAD &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;GROUP &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;PrimaryServerGroup&lt;br /&gt;USING PrimaryServerPool &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Step 3:&lt;/strong&gt; Creating user defined function which routes the workload to the appropriate workload group.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In this example we are checking&amp;nbsp;SUSER_NAME() and making the decision of Workgroup selection. We can use other functions such as&amp;nbsp;HOST_NAME(), APP_NAME(), IS_MEMBER() etc.&lt;br /&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;-----------------------------------------------&lt;br /&gt;-- Step 3: Create UDF to Route Workload Group&lt;br /&gt;-----------------------------------------------&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;CREATE FUNCTION &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;dbo.UDFClassifier&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;RETURNS SYSNAME&lt;br /&gt;WITH &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;SCHEMABINDING&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt;DECLARE &lt;/span&gt;&lt;span style=&quot;color: #434343;&quot;&gt;@WorkloadGroup &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;AS SYSNAME&lt;br /&gt;IF&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;SUSER_NAME&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;ReportUser&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SET &lt;/span&gt;&lt;span style=&quot;color: #434343;&quot;&gt;@WorkloadGroup &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;ReportServerGroup&#39;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;ELSE IF &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;SUSER_NAME&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;PrimaryUser&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SET &lt;/span&gt;&lt;span style=&quot;color: #434343;&quot;&gt;@WorkloadGroup &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;PrimaryServerGroup&#39;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;ELSE&lt;br /&gt;SET &lt;/span&gt;&lt;span style=&quot;color: #434343;&quot;&gt;@WorkloadGroup &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;default&#39;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;RETURN &lt;/span&gt;&lt;span style=&quot;color: #434343;&quot;&gt;@WorkloadGroup&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;Step 4:&lt;/strong&gt; In this final step we enable the resource governor with the classifier function created in earlier step 3.&lt;br /&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;-----------------------------------------------&lt;br /&gt;-- Step 4: Enable Resource Governer&lt;br /&gt;-- with UDFClassifier&lt;br /&gt;-----------------------------------------------&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;ALTER &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RESOURCE GOVERNOR&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;WITH &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;CLASSIFIER_FUNCTION&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;dbo.UDFClassifier&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;ALTER &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RESOURCE GOVERNOR &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;RECONFIGURE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; If you are following this demo and want to clean up your example, you should run following script. Running them will disable your resource governor as well delete all the objects created so far.&lt;br /&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;-----------------------------------------------&lt;br /&gt;-- Step 5: Clean Up&lt;br /&gt;-- Run only if you want to clean up everything&lt;br /&gt;-----------------------------------------------&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;ALTER &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RESOURCE GOVERNOR &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;WITH &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;CLASSIFIER_FUNCTION &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;NULL)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;ALTER &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RESOURCE GOVERNOR DISABLE&lt;br /&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;DROP FUNCTION &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;dbo.UDFClassifier&lt;br /&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;DROP &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;WORKLOAD &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;GROUP &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ReportServerGroup&lt;br /&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;DROP &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;WORKLOAD &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;GROUP &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;PrimaryServerGroup&lt;br /&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;DROP &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RESOURCE POOL ReportServerPool&lt;br /&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;DROP &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RESOURCE POOL PrimaryServerPool&lt;br /&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;ALTER &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RESOURCE GOVERNOR &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;RECONFIGURE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I hope this introductory example give enough light on the subject of Resource Governor. In future posts we will take this same example and learn a few more details.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Reference:&amp;nbsp;&lt;strong&gt;Pinal Dave (&lt;a href=&quot;http://blog.sqlauthority.com/&quot; target=&quot;_blank&quot;&gt;http://blog.sqlauthority.com&lt;/a&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/7758664866356058146/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/01/sql-server-simple-example-to-configure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/7758664866356058146'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/7758664866356058146'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/01/sql-server-simple-example-to-configure.html' title='SQL SERVER – Simple Example to Configure Resource Governor – Introduction to Resource Governor'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-2798312737801350707</id><published>2013-01-20T22:35:00.001-08:00</published><updated>2013-01-20T22:35:20.332-08:00</updated><title type='text'>SQL SERVER – A List of Various SQL Server RTM and Service Pack Number</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;posttitle&quot;&gt;
&lt;h2&gt;
&amp;nbsp;&lt;/h2&gt;
&lt;div class=&quot;post-info&quot;&gt;
January 18, 2013 by &lt;a href=&quot;http://blog.sqlauthority.com/author/pinaldave/&quot; title=&quot;Posts by pinaldave&quot;&gt;pinaldave&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;entry&quot; sizcache001617772947233892=&quot;1 2 0&quot; sizset=&quot;false&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
A common question I receive is that how do user know which version user is using and what is the latest version available for the product. Here is something at this beginning of the year, check with your production server. See if you are using the latest version of the product or if you need to upgrade. If you need to upgrade you might want to plan it with your entire team. As I get this question often here is something I have already built and kept it with me. As soon as I receive an email with the question about the version, I right away send it to them.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Now onwards as I have blogged about this subject, in future question, I will like to this blog post. Please feel free to add more details if I have missed any.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Here are two of the methods, you can use to identify your SQL Server version:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Open SSMS and in a New Query Window run following T-SQL code.&lt;/div&gt;
&lt;pre&gt;1) SELECT@@version
&lt;img alt=&quot;&quot; class=&quot;alignnone&quot; src=&quot;http://www.pinaldave.com/bimg/version@@.jpg&quot; width=&quot;500&quot; /&gt;
2) SELECT SERVERPROPERTY(&#39;&lt;span class=&quot;GRnoSuggestion&quot;&gt;productversion&lt;/span&gt;&#39;), SERVERPROPERTY (&#39;productlevel&#39;), SERVERPROPERTY (&#39;edition&#39;)
&lt;img alt=&quot;&quot; class=&quot;alignnone&quot; src=&quot;http://www.pinaldave.com/bimg/serverproperty.jpg&quot; width=&quot;500&quot; /&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The above query will return the version details of installed SQL Server.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Here is the list of the all the available RTM and Service Pack Numbers.&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
SQL Server 2012 Versions&lt;/h3&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Release&lt;/th&gt;&lt;th&gt;Product Version&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2012 Service Pack 1&lt;/td&gt;&lt;td&gt;11.00.3000.00&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2012 RTM&lt;/td&gt;&lt;td&gt;11.00.2100.60&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
SQL Server 2008 R2 Versions&lt;/h3&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Release&lt;/th&gt;&lt;th&gt;Product Version&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2008 R2 Service Pack 1&lt;/td&gt;&lt;td&gt;10.50.2500.0&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2008 R2 RTM&lt;/td&gt;&lt;td&gt;10.50.1600.1&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
SQL Server 2008 Versions&lt;/h3&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Release&lt;/th&gt;&lt;th&gt;Product Version&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2008 Service Pack 3&lt;/td&gt;&lt;td&gt;10.00.5500.00&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2008 Service Pack 2&lt;/td&gt;&lt;td&gt;10.00.4000.00&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2008 Service Pack 1&lt;/td&gt;&lt;td&gt;10.00.2531.00&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2008 RTM&lt;/td&gt;&lt;td&gt;10.00.1600.22&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
SQL Server 2005 Versions&lt;/h3&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Release&lt;/th&gt;&lt;th&gt;Product version&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2005 Service Pack 4&lt;/td&gt;&lt;td&gt;9.00.5000.00&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2005 Service Pack 3&lt;/td&gt;&lt;td&gt;9.00.4035&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2005 Service Pack 2&lt;/td&gt;&lt;td&gt;9.00.3042&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2005 Service Pack 1&lt;/td&gt;&lt;td&gt;9.00.2047&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2005 RTM&lt;/td&gt;&lt;td&gt;9.00.1399&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
SQL Server 2000 Versions&lt;/h3&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Release&lt;/th&gt;&lt;th&gt;Product version&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2000 Service Pack 4&lt;/td&gt;&lt;td&gt;8.00.2039&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2000 Service Pack 3&lt;/td&gt;&lt;td&gt;8.00.760&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2000 Service Pack 3&lt;/td&gt;&lt;td&gt;8.00.760&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2000 Service Pack 2&lt;/td&gt;&lt;td&gt;8.00.534&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2000 Service Pack 1&lt;/td&gt;&lt;td&gt;8.00.384&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SQL Server 2000 RTM&lt;/td&gt;&lt;td&gt;8.00.194&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
This method will help us find edition of the relational database. In future blog posts we will see the methods to identify the version of the Business Intelligence Services.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Reference:&amp;nbsp;&lt;strong&gt;Pinal Dave (&lt;a href=&quot;http://blog.sqlauthority.com/&quot; target=&quot;_blank&quot;&gt;http://blog.sqlauthority.com&lt;/a&gt;)&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/2798312737801350707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/01/sql-server-list-of-various-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/2798312737801350707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/2798312737801350707'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/01/sql-server-list-of-various-sql-server.html' title='SQL SERVER – A List of Various SQL Server RTM and Service Pack Number'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-970803897789035904</id><published>2013-01-20T22:30:00.002-08:00</published><updated>2013-01-20T22:30:52.437-08:00</updated><title type='text'>What is Collation?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h5 class=&quot;uiStreamMessage userContentWrapper&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:1,&amp;quot;tn&amp;quot;:&amp;quot;K&amp;quot;}&quot;&gt;
&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;div&gt;
&lt;span class=&quot;userContent&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Collation refers to a set of rules that determine how data is sorted and compared. Character data is sorted using rules that define the correct character sequence with options for specifying case sensitivity, accent marks, Kana character types, and character width. &lt;br /&gt;&lt;br /&gt;(Read more here &lt;/span&gt;&lt;a href=&quot;http://www.facebook.com/l.php?u=http%3A%2F%2Fow.ly%2FgSP8A&amp;amp;h=EAQEVEI6SAQHehdRCek0JGJT4XccU0Xu3BT8_KA-9Tng2Rg&amp;amp;s=1&quot; rel=&quot;nofollow nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;http://ow.ly/gSP8A&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-size: large;&quot;&gt; )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/h5&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/970803897789035904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2013/01/what-is-collation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/970803897789035904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/970803897789035904'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2013/01/what-is-collation.html' title='What is Collation?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-5353548848069355085</id><published>2012-12-20T23:33:00.000-08:00</published><updated>2012-12-20T23:33:27.876-08:00</updated><title type='text'>What are the Different Types of Triggers?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;userContent&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;text_exposed_root text_exposed&quot; id=&quot;id_50d4104a6e07b3c50180242&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;There are two types of Triggers.&lt;br /&gt;&lt;br /&gt;1) DML Trigger&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;text_exposed_hide&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;text_exposed_show&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt; There are two types of DML Triggers&lt;br /&gt;&lt;br /&gt;1.Instead of Trigger&lt;br /&gt;Instead of Triggers are fired in place of the triggering action such as an insert, update, or delete.&lt;br /&gt;&lt;br /&gt;2. After Trigger&lt;br /&gt;After triggers execute following the triggering action, such as an insert, update, or delete.&lt;br /&gt;&lt;br /&gt;2) DDL Trigger&lt;br /&gt;&lt;br /&gt;This type of trigger is fired against Drop Table, Create Table, Alter Table or Login events. DDL Triggers are always After Triggers.&lt;br /&gt;&lt;br /&gt;(Read more here &lt;/span&gt;&lt;a href=&quot;http://www.facebook.com/l.php?u=http%3A%2F%2Fow.ly%2FgbwHq&amp;amp;h=tAQG1IXcBAQHok5jAqKJM6vmh7_ImJrIm0iIxYj_E7C-TJw&amp;amp;s=1&quot; rel=&quot;nofollow nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;http://ow.ly/gbwHq&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-size: large;&quot;&gt; )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/5353548848069355085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2012/12/what-are-different-types-of-triggers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/5353548848069355085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/5353548848069355085'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2012/12/what-are-different-types-of-triggers.html' title='What are the Different Types of Triggers?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4095189091918776754.post-362316424953449118</id><published>2012-12-19T22:30:00.003-08:00</published><updated>2012-12-19T22:30:59.630-08:00</updated><title type='text'>What is a Trigger?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h5 class=&quot;uiStreamMessage userContentWrapper&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:1,&amp;quot;tn&amp;quot;:&amp;quot;K&amp;quot;}&quot;&gt;
&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;div&gt;
&lt;span class=&quot;userContent&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-size: large;&quot;&gt;A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or UPDATE) occurs. Triggers are stored in and managed by the DBMS. Triggers are used to maintain the referential integrity of data by changing the data in a systematic fashion. A trigger cannot be called or executed; DBMS automatically fires the trigger as a result of a data modification to the associated table. Triggers can be considered to be similar to stored procedures in that both consist of procedural logic that is stored at the database level. Stored procedures, however, are not event-drive and are not attached to a specific table as triggers are. Stored procedures are explicitly executed by invoking a CALL to the procedure while triggers are implicitly executed. In addition, triggers can also execute stored procedures.&lt;br /&gt;&lt;br /&gt;Nested Trigger: A trigger can also contain INSERT, UPDATE and DELETE logic within itself; so when the trigger is fired because of data modification, it can also cause another data modification, thereby firing another trigger. A trigger that contains data modification logic within itself is called a nested trigger.&lt;br /&gt;&lt;br /&gt;(Read more here &lt;/span&gt;&lt;a href=&quot;http://ow.ly/gbwDn&quot; rel=&quot;nofollow nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;http://ow.ly/gbwDn&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-size: large;&quot;&gt; )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/h5&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqlqandans.blogspot.com/feeds/362316424953449118/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlqandans.blogspot.com/2012/12/what-is-trigger.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/362316424953449118'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4095189091918776754/posts/default/362316424953449118'/><link rel='alternate' type='text/html' href='http://sqlqandans.blogspot.com/2012/12/what-is-trigger.html' title='What is a Trigger?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>