<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3739073232502260520</id><updated>2012-01-22T16:50:03.165-08:00</updated><category term='Connection Pool'/><category term='Denali'/><category term='Performance'/><category term='hotmail'/><category term='CHECKSUM'/><category term='SQL'/><category term='ADOMD'/><category term='Article'/><category term='RAID'/><category term='Table Variable'/><category term='PowerPivot'/><category term='Query Plan'/><category term='ISNULL'/><category term='Analysis Services'/><category term='Cardinality'/><category term='TCP IP'/><category term='Report Viewer Control'/><category term='Sri Lanka'/><category term='Windows 2008 R2'/><category term='Spatial Data'/><category term='TABLE TYPE'/><category term='SSIS'/><category term='GROUPING SETS'/><category term='CC'/><category term='Microsoft Certifications'/><category term='TORN_PAGE_DETECTION'/><category term='Self-Service Business Intelligence'/><category term='Slowly Changing Dimensions'/><category term='SQL Server Integration Services 2008'/><category term='SharePoint 2010'/><category term='Map'/><category term='Parameters'/><category term='PivotViewer'/><category term='MERGE'/><category term='HTML'/><category term='BPA'/><category term='MDX'/><category term='Microsoft Office Web Apps'/><category term='SQL Server Reporting Services 2008'/><category term='Excel'/><category term='SQL Server Reporting Services 2008 R2'/><category term='ALL'/><category term='Estimated Number of Rows'/><category term='Sleeping Status'/><category term='ANY'/><category term='Common Criteria Compliance'/><category term='SQL Server'/><category term='Replication'/><category term='Oracle 10g'/><category term='Service Pack'/><category term='Survey'/><category term='Report Templates'/><category term='Security'/><category term='Oracle'/><category term='Updatable Subscription'/><category term='Business Intelligence'/><category term='AVG'/><category term='Dimension'/><category term='TOP'/><category term='HAVING'/><category term='IDENTITY'/><category term='DATETIME'/><category term='SQL Azure'/><category term='Office 2007'/><category term='Textbox'/><category term='SP2'/><category term='Distributed Queries'/><category term='OPENROWSET'/><category term='Host Header'/><category term='SQL Server 2010'/><category term='Tech Insights'/><category term='Book Review'/><category term='Best Practice Analyzer'/><category term='SQL Server 2008'/><category term='Project Crescent'/><category term='Placeholder'/><category term='OPENDATASOURCE'/><category term='PerformancePoint'/><category term='6231A'/><category term='Doughnut Chart'/><category term='Office 2010'/><category term='PAGE compression'/><category term='TSQL'/><category term='SQLNCLI'/><category term='TABLESAMPLE'/><category term='ISO 8601'/><category term='RDLC'/><category term='Management Studio'/><category term='BI'/><category term='GROUP BY'/><category term='DELETE'/><category term='Tooltip'/><category term='Degenerated Dimension'/><category term='Data Warehousing'/><category term='SQL Server 2008 R2'/><category term='Disaster Recovery'/><category term='Named Pipe'/><category term='Silverlight'/><category term='PAGE_VERIFY'/><title type='text'>Dinesh's Blog :::: Being Compiled ::::</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default?start-index=101&amp;max-results=100'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>167</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-3253548950672808208</id><published>2012-01-22T16:45:00.001-08:00</published><updated>2012-01-22T16:50:03.175-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='TABLE TYPE'/><category scheme='http://www.blogger.com/atom/ns#' term='MERGE'/><title type='text'>TABLE Type and MERGE Statement</title><content type='html'>&lt;p align="justify"&gt;As I get many offline questions regarding the presentation “Reducing RoundTrips” I did, thought to summarize the content we discussed as a post. Session spoke about how to reduce multiple database calls from client to database application when an updated data set (Ex. data table bound to a grid) is required to send from client application to database. In addition to that we discussed the way of handling all three operations: INSERT, UPDATE, and DELETE using a single statement. This is what the session focused on;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;MERGE&lt;/strong&gt;     &lt;br /&gt;MERGE statement is used to insert data that does not exist but to update if it does exist. It is an extension of UPSERT which is a known term in other database management systems for performing both UPDATE and INSERT statement using a single technique. The main benefit of this is the facility to manipulate many number of records in a single table using a source as an atomic operation. This eliminates individual statements for INSERT, UPDATE and DELETE operations, one statement which is MERGE handles all three operations. MERGE statement has following elements;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Target: This the table or view (destination) which needs to be updated.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Source: This contains updated data (modified, newly added) and will be used for updating the target. This can be a table, view, derived table, CTE, or table function.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;WHEN MATCHED [AND] ...... THEN: This is where the action which needs to be performed when the row in the source is found in the target, should be written. Two WHEN MATCHED clauses are allowed, limiting one for UPDATE as an action and other for DELETE as an action.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;WHEN NOT MATCHED [BY TARGET] ...... THEN: The action which performs when the row in the source is not found in the target, has to be written with this. It is usually the INSERT action.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;WHEN NOT MATCHED [BY SOURCE] ...... THEN: This is to perform an action when the row in the target is not supplied with the source. Usually it is DELETE.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;OUTPUT clause and $Action: The standard inserted and deleted virtual tables are available with MERGE. In addition to that $Action provides the operation performed; INSERT, UPDATE, DELETE. This is normally used for logging/auditing.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;In order to use MERGE, a source must be defined and filled. Usually the source is defined and filled by the client but for various limitations and less facilities, we used to iterate the filled-source at the client site itself and send one row at a time to database, which makes many calls to database for updating all records in the source.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;TABLE Type&lt;/strong&gt;     &lt;br /&gt;This can be overcome using TABLE data type. TABLE data type can be created as a user-defined data type definition and can be used as either variable or parameter. Following are the key elements of creating a type;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;CREATE TYPE: This is used for creating the user defined type. It has to be created as a TABLE and structure has to be defined.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;READONLY keyword: If the type is used as a parameter, READONLY keyword has to be used. It is as an OUTPUT parameter is not supported.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;SqlDbType.Structured: When a data table from a .NET application is sent, parameter data type must be declared as System.Data.SqlDbType.Structured.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here is a sample code for all;&lt;/p&gt;  &lt;p align="justify"&gt;This code creates a table called Customer and inserts 4 rows. In addition to that it creates a log table too, for recording operations.&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;USE&lt;/span&gt; tempdb&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="rem"&gt;-- create a table for customer&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; dbo.Customer&lt;/pre&gt;

  &lt;pre&gt;(&lt;/pre&gt;

  &lt;pre class="alt"&gt;    CustomerId &lt;span class="kwrd"&gt;int&lt;/span&gt; &lt;span class="kwrd"&gt;identity&lt;/span&gt;(1,1) &lt;span class="kwrd"&gt;not&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    , CustomerCode &lt;span class="kwrd"&gt;char&lt;/span&gt;(4) &lt;span class="kwrd"&gt;not&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    , FirstName &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(25) &lt;span class="kwrd"&gt;null&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    , LastName &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(25) &lt;span class="kwrd"&gt;not&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    , CreditLimit money &lt;span class="kwrd"&gt;not&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    , IsLocal &lt;span class="kwrd"&gt;bit&lt;/span&gt; &lt;span class="kwrd"&gt;not&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    , LastModified smalldatetime &lt;span class="kwrd"&gt;not&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="rem"&gt;-- insert four records&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;INSERT &lt;span class="kwrd"&gt;INTO&lt;/span&gt; Customer&lt;/pre&gt;

  &lt;pre class="alt"&gt;    (CustomerCode, FirstName, LastName, CreditLimit, IsLocal, LastModified)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;VALUES&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    (&lt;span class="str"&gt;'C001'&lt;/span&gt;, &lt;span class="str"&gt;'Dinesh'&lt;/span&gt;, &lt;span class="str"&gt;'Priyankara'&lt;/span&gt;, 10000, 1, getdate())&lt;/pre&gt;

  &lt;pre&gt;    , (&lt;span class="str"&gt;'C002'&lt;/span&gt;, &lt;span class="str"&gt;'Jane'&lt;/span&gt;, &lt;span class="str"&gt;'K'&lt;/span&gt;, 10000, 1, getdate())&lt;/pre&gt;

  &lt;pre class="alt"&gt;    , (&lt;span class="str"&gt;'C003'&lt;/span&gt;, &lt;span class="str"&gt;'Martinie'&lt;/span&gt;, &lt;span class="str"&gt;'Ku'&lt;/span&gt;, 10000, 0, getdate())&lt;/pre&gt;

  &lt;pre&gt;    , (&lt;span class="str"&gt;'C004'&lt;/span&gt;, &lt;span class="str"&gt;'Joe'&lt;/span&gt;, &lt;span class="str"&gt;'Anderson'&lt;/span&gt;, 10000, 0, getdate())&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; dbo.CustomerLog&lt;/pre&gt;

  &lt;pre&gt;(&lt;/pre&gt;

  &lt;pre class="alt"&gt;    CustomerCode &lt;span class="kwrd"&gt;char&lt;/span&gt;(4) &lt;span class="kwrd"&gt;not&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    , DateModified datetime &lt;span class="kwrd"&gt;not&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    , &lt;span class="kwrd"&gt;Action&lt;/span&gt; &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(15) &lt;span class="kwrd"&gt;not&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;)    &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p align="justify"&gt;Here is the stored procedure for accepting an updated data set using TABLE type and updating Customer using MERGE.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="rem"&gt;-- create a stored procedure for accepting created TABLE type as a parameter&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="rem"&gt;-- note that READONLY has to be used&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;PROC&lt;/span&gt; dbo.InsertCustomer @CustomerType dbo.CustomerType READONLY&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;AS&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    INSERT &lt;span class="kwrd"&gt;INTO&lt;/span&gt; dbo.CustomerLog&lt;/pre&gt;

  &lt;pre&gt;    (CustomerCode, DateModified, [&lt;span class="kwrd"&gt;Action&lt;/span&gt;])&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;SELECT&lt;/span&gt; o.CustomerCode, getdate(), o.[&lt;span class="kwrd"&gt;Action&lt;/span&gt;]&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;FROM&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        (MERGE &lt;span class="kwrd"&gt;INTO&lt;/span&gt; dbo.Customer &lt;span class="kwrd"&gt;AS&lt;/span&gt; c&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;USING&lt;/span&gt; @CustomerType &lt;span class="kwrd"&gt;AS&lt;/span&gt; t&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;ON&lt;/span&gt; c.CustomerCode = t.CustomerCode&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; MATCHED &lt;span class="kwrd"&gt;AND&lt;/span&gt; t.IsLocal = 0 &lt;span class="kwrd"&gt;THEN&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;UPDATE&lt;/span&gt; &lt;span class="kwrd"&gt;SET&lt;/span&gt; c.FirstName = t. FirstName&lt;/pre&gt;

  &lt;pre&gt;                    , c.LastName = t.LastName&lt;/pre&gt;

  &lt;pre class="alt"&gt;                    , c.CreditLimit = t.CreditLimit&lt;/pre&gt;

  &lt;pre&gt;                    , c.LastModified = getdate()&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; &lt;span class="kwrd"&gt;NOT&lt;/span&gt; MATCHED &lt;span class="kwrd"&gt;THEN&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;            INSERT (CustomerCode, FirstName, LastName, CreditLimit, IsLocal, LastModified)&lt;/pre&gt;

  &lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;VALUES&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;                    (t.CustomerCode, t.FirstName, t.LastName, t.CreditLimit, t.IsLocal, getdate())&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; &lt;span class="kwrd"&gt;NOT&lt;/span&gt; MATCHED &lt;span class="kwrd"&gt;BY&lt;/span&gt; SOURCE &lt;span class="kwrd"&gt;THEN&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;DELETE&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;OUTPUT&lt;/span&gt; isnull(inserted.CustomerCode, deleted.CustomerCode) &lt;span class="kwrd"&gt;as&lt;/span&gt; CustomerCode, $&lt;span class="kwrd"&gt;ACTION&lt;/span&gt; &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;span class="kwrd"&gt;Action&lt;/span&gt;) &lt;span class="kwrd"&gt;AS&lt;/span&gt; o&lt;/pre&gt;

  &lt;pre&gt;            &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;END&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;
  &lt;p&gt;Everything is ready from database level. Here is a sample code for .NET application.&lt;/p&gt;

  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;SqlConnection connection = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlConnection(&lt;span class="str"&gt;@&amp;quot;Server=.\SQL2008R2;Integrated Security=SSPI;Database=tempdb&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre&gt;DataTable customer = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataTable(&lt;span class="str"&gt;&amp;quot;Customer&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre class="alt"&gt;customer.Columns.Add(&lt;span class="str"&gt;&amp;quot;CustomerCode&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt;));&lt;/pre&gt;

    &lt;pre&gt;customer.Columns.Add(&lt;span class="str"&gt;&amp;quot;FirstName&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt;));&lt;/pre&gt;

    &lt;pre class="alt"&gt;customer.Columns.Add(&lt;span class="str"&gt;&amp;quot;LastName&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt;));&lt;/pre&gt;

    &lt;pre&gt;customer.Columns.Add(&lt;span class="str"&gt;&amp;quot;CreditLimit&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;decimal&lt;/span&gt;));&lt;/pre&gt;

    &lt;pre class="alt"&gt;customer.Columns.Add(&lt;span class="str"&gt;&amp;quot;IsLocal&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;bool&lt;/span&gt;));&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;customer.Rows.Add(&lt;span class="str"&gt;&amp;quot;C001&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Dinesh&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Priyankara&amp;quot;&lt;/span&gt;, 10000, &lt;span class="kwrd"&gt;true&lt;/span&gt;); &lt;span class="rem"&gt;// no change and no update&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;customer.Rows.Add(&lt;span class="str"&gt;&amp;quot;C002&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Jane&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Kani&amp;quot;&lt;/span&gt;, 25000, &lt;span class="kwrd"&gt;true&lt;/span&gt;); &lt;span class="rem"&gt;// should not update&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;customer.Rows.Add(&lt;span class="str"&gt;&amp;quot;C004&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Joe&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Andrew&amp;quot;&lt;/span&gt;, 35000, &lt;span class="kwrd"&gt;true&lt;/span&gt;); &lt;span class="rem"&gt;// update all&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;customer.Rows.Add(&lt;span class="str"&gt;&amp;quot;C005&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Kate&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Neo&amp;quot;&lt;/span&gt;, 35000, &lt;span class="kwrd"&gt;true&lt;/span&gt;); &lt;span class="rem"&gt;// new record&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;SqlCommand command = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlCommand(&lt;span class="str"&gt;&amp;quot;InsertCustomer&amp;quot;&lt;/span&gt;, connection);  &lt;/pre&gt;

    &lt;pre class="alt"&gt;command.CommandType = CommandType.StoredProcedure;&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;SqlParameter parameter = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlParameter(&lt;span class="str"&gt;&amp;quot;@CustomerType&amp;quot;&lt;/span&gt;, System.Data.SqlDbType.Structured);&lt;/pre&gt;

    &lt;pre&gt;parameter.Value = customer;&lt;/pre&gt;

    &lt;pre class="alt"&gt;command.Parameters.Add(parameter);&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;connection.Open();&lt;/pre&gt;

    &lt;pre&gt;command.ExecuteNonQuery();&lt;/pre&gt;

    &lt;pre class="alt"&gt;connection.Close();&lt;/pre&gt;
  &lt;/div&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-3253548950672808208?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/3253548950672808208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=3253548950672808208&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3253548950672808208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3253548950672808208'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2012/01/table-type-and-merge-statement.html' title='TABLE Type and MERGE Statement'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-4025160749311531110</id><published>2011-11-01T02:10:00.001-07:00</published><updated>2011-11-01T02:10:24.410-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><title type='text'>Is SQL Server @@IDENTITY a Global Function?</title><content type='html'>&lt;p align="justify"&gt;The @@IDENTITY is a system function that returns last generated identity value. But the question is, is it the last identity generated by my code? Last generated by my session? Or last generated by the system for any user?&lt;/p&gt;  &lt;p align="justify"&gt;Understanding what exactly it returns help you to code your database modules accurately. Let’s try this with a small example.&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; T1 (Id &lt;span class="kwrd"&gt;int&lt;/span&gt; &lt;span class="kwrd"&gt;IDENTITY&lt;/span&gt;(1,1), &lt;span class="kwrd"&gt;Value&lt;/span&gt; &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(20))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; T2 (Id &lt;span class="kwrd"&gt;int&lt;/span&gt; &lt;span class="kwrd"&gt;IDENTITY&lt;/span&gt;(100,1), &lt;span class="kwrd"&gt;Value&lt;/span&gt; &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(20))&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;PROC&lt;/span&gt; InsertT2&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;AS&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    INSERT &lt;span class="kwrd"&gt;INTO&lt;/span&gt; T2 (&lt;span class="kwrd"&gt;Value&lt;/span&gt;) &lt;span class="kwrd"&gt;VALUES&lt;/span&gt; (&lt;span class="str"&gt;'Test'&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;END&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;PROC&lt;/span&gt; InsertT1&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;AS&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    INSERT &lt;span class="kwrd"&gt;INTO&lt;/span&gt; T1 (&lt;span class="kwrd"&gt;Value&lt;/span&gt;) &lt;span class="kwrd"&gt;VALUES&lt;/span&gt; (&lt;span class="str"&gt;'Test'&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;EXEC&lt;/span&gt; InsertT2&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="preproc"&gt;@@IDENTITY&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;SELECT&lt;/span&gt; SCOPE_IDENTITY()&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;END&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;EXEC&lt;/span&gt; InsertT1&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;br /&gt;

&lt;p align="justify"&gt;The result of InsertT1 execution will 100 and 1. As you see in the result, @@IDENTITY returns the last generated identity value for my session, not for the scope I am in. If you use this function to get the last generated identity value for your insert, result of it may be wrong unless no other code is executed that inserts a record to another table with IDENTITY property enabled. Note that SCOPE_IDENTITY returns the identity value for the scope, hence if the requirement is for get the value generated for current scope, use it.&lt;/p&gt;

&lt;p align="justify"&gt;There is another function that can be used for getting generated identity value, which is called IDENT_CURRENT. This function accepts the table name as a parameter and returns the last generated identity value for given table, by any scope, any session, any connection.
  &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-4025160749311531110?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/4025160749311531110/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=4025160749311531110&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4025160749311531110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4025160749311531110'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/11/is-sql-server-identity-global-function.html' title='Is SQL Server @@IDENTITY a Global Function?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-4909235715670611619</id><published>2011-09-19T18:00:00.001-07:00</published><updated>2011-09-19T18:00:34.349-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Parameters'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Reporting Services 2008'/><title type='text'>Reporting Services Parameters: Adding “All” item.</title><content type='html'>&lt;p align="justify"&gt;There are some instances we have to create parameters with multiple items, including an item representing all items in the list, mostly called as “All”. There are various ways of doing it. If the list is dynamic and data source is OLAP, you get this item automatically. If it is not OLAP, and loading from OLTP database, this item has to be manually added and programmatically handled.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/-qBOUdjQLhTs/TnfloDKOPvI/AAAAAAAAA5Q/oP4PZ-1V6IM/s1600-h/Image1%25255B2%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image1" border="0" alt="Image1" src="http://lh3.ggpht.com/-uthHFKKfk8g/TnflqwcUuSI/AAAAAAAAA5U/-K9vbXCbPTk/Image1_thumb.png?imgmax=800" width="198" height="176" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Here is an easy way to handle it. Have this additional item in a new query and use UNION for joining it to main query.&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  &lt;span class="str"&gt;'All Years'&lt;/span&gt; &lt;span class="kwrd"&gt;AS&lt;/span&gt; OrderYear&lt;/pre&gt;

  &lt;pre&gt;    , 0 &lt;span class="kwrd"&gt;AS&lt;/span&gt; OrderYearValue&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;UNION&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;DISTINCT&lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;varchar&lt;/span&gt;(100), &lt;span class="kwrd"&gt;YEAR&lt;/span&gt;(OrderDate)) &lt;span class="kwrd"&gt;AS&lt;/span&gt; OrderYear&lt;/pre&gt;

  &lt;pre&gt;    , &lt;span class="kwrd"&gt;YEAR&lt;/span&gt;(OrderDate)  &lt;span class="kwrd"&gt;as&lt;/span&gt; OrderYearValue&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;FROM&lt;/span&gt; Sales.SalesOrderHeader&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; 2&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p align="justify"&gt;Now data source contains the item. In order to get this handled with query parameter, follow below code;&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; {your columns}&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;FROM&lt;/span&gt; Sales.SalesOrderHeader&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;WHERE&lt;/span&gt; &lt;span class="kwrd"&gt;YEAR&lt;/span&gt;(OrderDate) = @&lt;span class="kwrd"&gt;Year&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;OR&lt;/span&gt; @&lt;span class="kwrd"&gt;Year&lt;/span&gt; = 0&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p align="justify"&gt;Happy Coding &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://lh5.ggpht.com/-lN7sqVk7sgU/Tnflr86yMaI/AAAAAAAAA5Y/Q7Ws_n-zNSI/wlEmoticon-smile%25255B2%25255D.png?imgmax=800" /&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-4909235715670611619?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/4909235715670611619/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=4909235715670611619&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4909235715670611619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4909235715670611619'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/09/reporting-services-parameters-adding.html' title='Reporting Services Parameters: Adding “All” item.'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/-uthHFKKfk8g/TnflqwcUuSI/AAAAAAAAA5U/-K9vbXCbPTk/s72-c/Image1_thumb.png?imgmax=800' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-8032072495577122842</id><published>2011-08-31T21:23:00.001-07:00</published><updated>2011-08-31T21:23:55.128-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SSIS'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Integration Services 2008'/><title type='text'>PIVOT and UNPIVOT: Integration Services</title><content type='html'>&lt;p align="justify"&gt;As you all know, Pivoting and Unpivoting are supported with SSIS but the implementation of PIVOTing is bit difficult when compared with UNPIVOTing. This post explains the implementation of both PIVOT and UNPIVOT transformations that come with SSIS with all possible explanations.&lt;/p&gt;  &lt;p align="justify"&gt;Pivot allows us to convert normalized dataset into less normalized format, transferring (pivoting) row values into columns. In simple term, it identifies distinct values in a designated column and makes columns based on identified values (note that it is not fully dynamic and automated). Here is an example.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/-JjU8qQOzuh4/Tl8IoIDgElI/AAAAAAAAA4A/Ajb_3m4loLM/s1600-h/Image1%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image1" border="0" alt="Image1" src="http://lh3.ggpht.com/-vg8YKfo4dhY/Tl8IpeYaRII/AAAAAAAAA4E/LbyV_w9E_PU/Image1_thumb%25255B1%25255D.png?imgmax=800" width="401" height="255" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Example shows how PIVOT works, you can see that values (months) in &lt;strong&gt;&lt;em&gt;OrderMonth&lt;/em&gt;&lt;/strong&gt; column have been converted into columns, combining with &lt;strong&gt;&lt;em&gt;OrderAmount&lt;/em&gt;&lt;/strong&gt; column. Now let’s see how we can do this with SSIS. The code below is the source for pivoting that returns Orders placed by customers for months and years.&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;  &lt;span class="kwrd"&gt;YEAR&lt;/span&gt;(OrderDate) OrderYear&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;   , p.LastName Customer&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;  , DATENAME(mm, OrderDate) OrderMonth&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;  , &lt;span class="kwrd"&gt;SUM&lt;/span&gt;(SubTotal) OrderAmount&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&lt;span class="kwrd"&gt;FROM&lt;/span&gt; Sales.SalesOrderHeader h&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;  &lt;span class="kwrd"&gt;INNER&lt;/span&gt; &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; Sales.Customer c&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    &lt;span class="kwrd"&gt;ON&lt;/span&gt; c.CustomerID = h.CustomerID&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;  &lt;span class="kwrd"&gt;INNER&lt;/span&gt; &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; Person.Person p    &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="kwrd"&gt;ON&lt;/span&gt; p.BusinessEntityID = c.PersonID&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;&lt;span class="kwrd"&gt;GROUP&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;  &lt;span class="kwrd"&gt;YEAR&lt;/span&gt;(OrderDate)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;  ,p.LastName&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;  ,DATENAME(mm, OrderDate)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; 1, 2&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p align="justify"&gt;In order to do this in SSIS, create a new project and have a &lt;strong&gt;&lt;em&gt;Data Flow Task&lt;/em&gt;&lt;/strong&gt; in &lt;em&gt;&lt;strong&gt;Control Flow&lt;/strong&gt;. &lt;/em&gt;Place an OLE DB Data Source in &lt;strong&gt;&lt;em&gt;Data Flow Task&lt;/em&gt;&lt;/strong&gt; and set the above query, making the connection to &lt;strong&gt;AdventureWorks2008R2&lt;/strong&gt; database. Then, drag &lt;strong&gt;&lt;em&gt;PIVOT&lt;/em&gt;&lt;/strong&gt; transformation on to &lt;strong&gt;&lt;em&gt;Data Flow&lt;/em&gt;&lt;/strong&gt; and connect them using &lt;strong&gt;&lt;em&gt;Connection Line&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/-43aCJstSQ3g/Tl8IqF83ExI/AAAAAAAAA4I/-bOaQr1WoUg/s1600-h/post53.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="post5" border="0" alt="post5" src="http://lh6.ggpht.com/-Cn3XLuv3ewo/Tl8Iq2eXD8I/AAAAAAAAA4M/M2Viih6vz7U/post5_thumb1.png?imgmax=800" width="246" height="136" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Pivot configuration is little bit tricky, not as easy as &lt;strong&gt;&lt;em&gt;T-SQL PIVOT&lt;/em&gt;&lt;/strong&gt;. When you open the &lt;strong&gt;&lt;em&gt;Editor&lt;/em&gt;&lt;/strong&gt; of it, you get three tabs. Second tab allows you to marks columns for pivoting, selecting them from input flow.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font color="#333333"&gt;&lt;a href="http://lh3.ggpht.com/-6EHM9c-6JlI/Tl8IrnhNcrI/AAAAAAAAA4Q/Iv3VXPaFu7A/s1600-h/post63.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="post6" border="0" alt="post6" src="http://lh4.ggpht.com/-Ku-xAjw_aaw/Tl8Isb2XfjI/AAAAAAAAA4U/DecnJ_MEuGo/post6_thumb1.png?imgmax=800" width="396" height="365" /&gt;&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font color="#333333"&gt;Next tab which is &lt;strong&gt;&lt;em&gt;Input and Output Properties,&lt;/em&gt;&lt;/strong&gt; is for instructing SSIS the way of using input columns for pivot operation. The &lt;strong&gt;&lt;em&gt;Pivot Default Input&lt;/em&gt;&lt;/strong&gt; node in left pane allows us to set the usage of input columns for pivoting. The &lt;strong&gt;&lt;em&gt;Pivot Default Output&lt;/em&gt;&lt;/strong&gt; allows us to form the output columns based on input columns and their usage. Let’s first have a look on &lt;strong&gt;&lt;em&gt;Pivot Default Input&lt;/em&gt;&lt;/strong&gt; node.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;If you expand the next level of &lt;strong&gt;&lt;em&gt;Pivot Default Input&lt;/em&gt;&lt;/strong&gt;, which is &lt;strong&gt;&lt;em&gt;Input Columns&lt;/em&gt;&lt;/strong&gt;, you can see all columns available for the operation. Selecting one column loads its properties to right pane, which contains a property called &lt;strong&gt;&lt;em&gt;PivotUsage&lt;/em&gt;&lt;/strong&gt; that accepts a numeric value from 0 to 3. Here is the way of deciding the value for &lt;strong&gt;&lt;em&gt;PivotUsage&lt;/em&gt;&lt;/strong&gt; property.&lt;/p&gt;

&lt;table border="1" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="41"&gt;&lt;font color="#c0504d"&gt;&lt;strong&gt;Value&lt;/strong&gt;&lt;/font&gt;&lt;/td&gt;

      &lt;td valign="top" width="359"&gt;&lt;font color="#c0504d"&gt;&lt;strong&gt;Meaning&lt;/strong&gt;&lt;/font&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="41"&gt;&lt;strong&gt;0&lt;/strong&gt;&lt;/td&gt;

      &lt;td valign="top" width="359"&gt;Column does not participate in PIVOTing, it is passed through unchanged to the output. If PIVOTing identifies multiple values in an output row, only the first value of them will be used with the output row. 
        &lt;br /&gt;&lt;strong&gt;&lt;em&gt;In our example, we do not have any column to be marked as 0&lt;/em&gt;.&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="41"&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;/td&gt;

      &lt;td valign="top" width="359"&gt;Column is the key (Set key) for generating the pivot output rows. Values in this column will be used to identify unique values for rows. We can mark one or more columns as 1 but need to make sure that combination of them make record unique without providing any duplicates. 
        &lt;br /&gt;&lt;em&gt;&lt;strong&gt;In our example, we have to column to mark as 1: OrderYear and Customer.&lt;/strong&gt;&lt;/em&gt;&amp;#160;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="41"&gt;&lt;strong&gt;2&lt;/strong&gt;&lt;/td&gt;

      &lt;td valign="top" width="359"&gt;Values in this column (Pivot Column) will be used for creating columns in the pivot output. 
        &lt;br /&gt;&lt;em&gt;&lt;strong&gt;In our example, OrderMonth is the column which should be marked as 2.&lt;/strong&gt;&lt;/em&gt;&amp;#160;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="41"&gt;&lt;strong&gt;3&lt;/strong&gt;&lt;/td&gt;

      &lt;td valign="top" width="359"&gt;Values in this column will be used to generate the values for columns created from pivot column. 
        &lt;br /&gt;&lt;em&gt;&lt;strong&gt;In our example, OrderAmount should be set as 3.&lt;/strong&gt;&lt;/em&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p align="justify"&gt;Here is the way of setting it;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/-520qwCLr-AA/Tl8ItDsMuJI/AAAAAAAAA4Y/aMOYC8WUBUw/s1600-h/post113.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="post11" border="0" alt="post11" src="http://lh4.ggpht.com/-V0jPRkTH6tk/Tl8IuBPk55I/AAAAAAAAA4c/1tooZrjdSm0/post11_thumb1.png?imgmax=800" width="403" height="371" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Next step is configuring &lt;strong&gt;&lt;em&gt;Pivot Default Output&lt;/em&gt;. &lt;/strong&gt;If you expand the node, &lt;strong&gt;&lt;em&gt;Output Columns&lt;/em&gt;&lt;/strong&gt; node is appeared. In order to defines columns, including columns created through pivot column, we have to create them. Make sure you have selected &lt;strong&gt;&lt;em&gt;Output Columns&lt;/em&gt;&lt;/strong&gt; node and click on &lt;em&gt;&lt;strong&gt;Add Column&lt;/strong&gt; &lt;/em&gt;for creating 14 columns. Once the columns are created, name them with &lt;strong&gt;&lt;em&gt;Name&lt;/em&gt;&lt;/strong&gt; property as OrderYear, Customer, January, February, March, April, May, June, July, August, September, October, November, and December.&lt;/p&gt;

&lt;p align="justify"&gt;Next is, linking output columns with input columns. This will be done through a property called &lt;strong&gt;&lt;em&gt;SourceColumn&lt;/em&gt;&lt;/strong&gt; in output columns. The value of the &lt;strong&gt;&lt;em&gt;SourceColumn&lt;/em&gt;&lt;/strong&gt; has to be taken from relevant input column’s property called &lt;strong&gt;&lt;em&gt;LineageID&lt;/em&gt;&lt;/strong&gt;. Find the &lt;strong&gt;&lt;em&gt;LineageID &lt;/em&gt;&lt;/strong&gt;of &lt;strong&gt;&lt;em&gt;OrderYear&lt;/em&gt;&lt;/strong&gt; input column (in my case it is 17, see above image) and set it in &lt;strong&gt;&lt;em&gt;SourceColumn&lt;/em&gt;&lt;/strong&gt; of &lt;strong&gt;&lt;em&gt;OrderYear&lt;/em&gt;&lt;/strong&gt; output column. Do the same for &lt;strong&gt;&lt;em&gt;Customer&lt;/em&gt;&lt;/strong&gt; column too.&lt;/p&gt;

&lt;p align="justify"&gt;Next columns are month columns. The property &lt;strong&gt;&lt;em&gt;SourceColumn&lt;/em&gt;&lt;/strong&gt; of all month columns has to be set with &lt;strong&gt;&lt;em&gt;LineageID&lt;/em&gt;&lt;/strong&gt; of &lt;strong&gt;&lt;em&gt;OrderAmount&lt;/em&gt;&lt;/strong&gt;. In addition to that, a property called &lt;strong&gt;&lt;em&gt;PivotKeyValue&lt;/em&gt;&lt;/strong&gt; should be filled too. This property should be filled with values coming from &lt;strong&gt;&lt;em&gt;PivotColumn&lt;/em&gt;&lt;/strong&gt;. For example, &lt;strong&gt;&lt;em&gt;January&lt;/em&gt;&lt;/strong&gt; column’s property should be filled with “January”, and February column’s property should be filled with “February”.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/-rkRv670gGcM/Tl8Iuy1jPjI/AAAAAAAAA4g/oYXhPpFG-Ho/s1600-h/post123.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="post12" border="0" alt="post12" src="http://lh6.ggpht.com/-GK-21WRz8iE/Tl8Ivia4E2I/AAAAAAAAA4k/kgczwQuKA58/post12_thumb1.png?imgmax=800" width="398" height="364" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Package is done. Let’s send the output to an Excel file for testing purposes. Here is the package execution and the output of it.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/-5QRPdC-h_SI/Tl8IwbjGuJI/AAAAAAAAA4o/hmccWGfELWw/s1600-h/post132.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="post13" border="0" alt="post13" src="http://lh3.ggpht.com/-MB8xTQFliA8/Tl8IxODfDrI/AAAAAAAAA4s/b0CFI6P26eY/post13_thumb.png?imgmax=800" width="244" height="215" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/-0KmMQpX_7PQ/Tl8Iya4XH9I/AAAAAAAAA4w/fX4arnVMXjo/s1600-h/post43.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="post4" border="0" alt="post4" src="http://lh5.ggpht.com/-RBti4QXH2T4/Tl8IzSQ8ElI/AAAAAAAAA40/ZWEKYogWW3U/post4_thumb1.png?imgmax=800" width="404" height="219" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;SSIS UNPIVOT is not as tricky/difficult as PIVOT. Let’s see how UNPIVOTing can be done with SSIS. Easiest way to understand this is, reversing the process, unpivoting Excel sheet created with previous example. Let’s have a &lt;strong&gt;&lt;em&gt;Data Flow Task&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;Excel Source&lt;/em&gt;&lt;/strong&gt; on it, connecting to the Excel we created. Add an &lt;strong&gt;&lt;em&gt;Unpivot&lt;/em&gt;&lt;/strong&gt; transformation and connect it with the source.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/-K7gtW62oU4M/Tl8I0PXT3VI/AAAAAAAAA44/yDtdLB1qr8M/s1600-h/Image1%25255B6%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image1" border="0" alt="Image1" src="http://lh4.ggpht.com/-CkRvSPWRxNs/Tl8I01M9tJI/AAAAAAAAA48/RbxD8u0YAKw/Image1_thumb%25255B2%25255D.png?imgmax=800" width="229" height="169" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Let’s configure UNPIVOT transformation. Open the &lt;strong&gt;&lt;em&gt;Unpivot Transformation Editor&lt;/em&gt;&lt;/strong&gt; and configure it as follows;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;Select &lt;strong&gt;&lt;em&gt;Pass Through&lt;/em&gt;&lt;/strong&gt; checkbox only for &lt;strong&gt;&lt;em&gt;OrderYear&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;Customer&lt;/em&gt;&lt;/strong&gt;.&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;Select all month columns. This loads all months into the grid.&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;Give a destination column name (Eg. OrderAmount) for month columns. Make sure that same name is set for all columns. This column will hold values related to months.&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;Make sure &lt;strong&gt;&lt;em&gt;Pivot Key Value&lt;/em&gt;&lt;/strong&gt; has been properly set. This value will be set as a row value for column which will be unpivoted.&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;Finally, give a name for &lt;strong&gt;&lt;em&gt;Pivot Key Value&lt;/em&gt;&lt;/strong&gt; column (OrderMonth).&lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/-jKN_G7cg4p0/Tl8I1TJxhGI/AAAAAAAAA5A/cZf1eG7jXp4/s1600-h/Image1%25255B14%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image1" border="0" alt="Image1" src="http://lh3.ggpht.com/-HlwCO06hVNg/Tl8I2feifkI/AAAAAAAAA5E/9HdslIXzsfM/Image1_thumb%25255B6%25255D.png?imgmax=800" width="378" height="370" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Done. Have a destination as you want and see the result.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-8032072495577122842?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/8032072495577122842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=8032072495577122842&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/8032072495577122842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/8032072495577122842'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/08/pivot-and-unpivot-integration-services.html' title='PIVOT and UNPIVOT: Integration Services'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/-vg8YKfo4dhY/Tl8IpeYaRII/AAAAAAAAA4E/LbyV_w9E_PU/s72-c/Image1_thumb%25255B1%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-3126211482344469627</id><published>2011-07-10T20:39:00.001-07:00</published><updated>2011-07-10T20:39:14.688-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Integration Services 2008'/><title type='text'>Default Logging: Microsoft SQL Server Integration Services</title><content type='html'>&lt;p align="justify"&gt;Everybody knows how important logging is, when it comes for troubleshooting. It applies for SSIS packages too. Unfortunately, most of developers, pay not much attention for this, and later regret for not having any records on package executions. If you have not implemented any mechanisms for logging and need to know how often the package gets executed or whether the package is started, you are not stranded. Integration Services has done the needful for you.&lt;/p&gt;  &lt;p align="justify"&gt;Integration Services has a default logging behavior. It captures starting and ending events, and adds two log entries to Windows Event Viewer. If you run the package with Business Intelligence Studio while it is being designed, you should see two entries in Windows Event Viewer as follows;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/-5qzOcUdUAqU/ThpwWneW0AI/AAAAAAAAA20/deidy_-O-ug/s1600-h/image3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-Q6julnAT5A4/ThpwYPGR-oI/AAAAAAAAA24/Z9Oc2ayjxkU/image_thumb1.png?imgmax=800" width="399" height="154" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;This behavior cannot be stopped. It logs not only when the package is run with BIDS, with DTEXEC too. As per my experience this is not enough for troubleshooting if it is a complex package, so, make sure you have used other out-of-the-box logging features for recoding your package processes.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-3126211482344469627?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/3126211482344469627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=3126211482344469627&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3126211482344469627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3126211482344469627'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/07/default-logging-microsoft-sql-server.html' title='Default Logging: Microsoft SQL Server Integration Services'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/-Q6julnAT5A4/ThpwYPGR-oI/AAAAAAAAA24/Z9Oc2ayjxkU/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-5754459277614748254</id><published>2011-07-05T20:04:00.001-07:00</published><updated>2011-07-05T20:04:02.092-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>How the language “SQL” is born?</title><content type='html'>&lt;p align="justify"&gt;Simple thing that you may not know ……….&lt;/p&gt;  &lt;p align="justify"&gt;Structured Query Language was born in 1970, supporting Edgar F. Codd’s Relational Database Model. It was invented at IBM by Donald D. Chamberlin and Raymond F. Boyce (who introduced 3.5 NF) for IBM’s RDBMS called &lt;strong&gt;System R&lt;/strong&gt;. The initial name of it was &lt;strong&gt;Structured English Query Language (SEQUEL)&lt;/strong&gt; but changed to SQL later as SEQUEL was a trademark of another company.&lt;/p&gt;  &lt;p align="justify"&gt;The first commercially available implementation of SQL was released by &lt;strong&gt;Relational Software Inc.&lt;/strong&gt; (now known as &lt;strong&gt;Oracle Corporation&lt;/strong&gt;). It was in June 1979, for &lt;strong&gt;Oracle V2&lt;/strong&gt;. Relational Software Inc. started developing their own RDBMS based on Codd’s theories in 1970s.&lt;/p&gt;  &lt;p align="justify"&gt;Not only SQL, there were other RDBMS and SQL related languages. In 1970, University of California, Berkeley created a RDBMS named &lt;strong&gt;Ingres&lt;/strong&gt; (Known as Open Source RDBMS) and &lt;strong&gt;QUEL&lt;/strong&gt; was the language created for managing its data. With various different implementations, later it evolved into &lt;strong&gt;PostgreSQL&lt;/strong&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;IBM continued with its System R and SQL Implementation, making it as a commercial product named &lt;strong&gt;System38&lt;/strong&gt;. It was in 1979. Now it has been evolved into &lt;strong&gt;DB2&lt;/strong&gt; which was released in 1983.&lt;/p&gt;  &lt;p align="justify"&gt;SQL has many extensions now. Some of them are;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Oracle – PL/SQL&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;IBM – SQL PL&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Microsoft – T-SQL&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;SQL was standardized by &lt;strong&gt;American National Standard Institute (ANSI)&lt;/strong&gt; in 1986 as SQL-86. In 1987, it was standardized by International Organization for Standardization (ISO) too. It has been revised in many times, starting with SQL-86 to SQL:2008. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-5754459277614748254?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/5754459277614748254/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=5754459277614748254&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5754459277614748254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5754459277614748254'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/07/how-language-sql-is-born.html' title='How the language “SQL” is born?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-5891956696943549832</id><published>2011-07-03T21:00:00.001-07:00</published><updated>2011-07-03T21:00:29.422-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Integration Services 2008'/><title type='text'>Script Task cannot be debugged: Integration Services</title><content type='html'>&lt;p align="justify"&gt;If you run on 64-bit environment and try to debug a script task after placing a breakpoint, it is not going to work as you expect. The reason for this is 64-bit environment. There are few things that do not support on 64-bit mode but you can still configure them with 32-bit SSIS designer; Business Intelligence Development Studio. If you experience problems such as connecting to Excel via Microsoft OLE DB Provider for Jet or debugging Script task, while running in 64-bit mode, all you have to do is, changing the SSIS runtime into 32-bit. This is done by changing a property called &lt;strong&gt;Run64BitRuntime&lt;/strong&gt; on the Debugging page. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/-VBLmb1vgoz4/ThE62JJgj2I/AAAAAAAAA2s/AK0QjGmr0a8/s1600-h/image%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-A_JrvcPfnjk/ThE6205lgoI/AAAAAAAAA2w/oEHRJ1_OXYU/image_thumb%25255B1%25255D.png?imgmax=800" width="406" height="255" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Note that this property is used and applied only at design time. When you execute the package in a production server, environment for it is based on installed dtexec utility. The dtexec utility is available in 64-bit mode. If you execute the package in 64-bit environment, 64-bit dtexec will be automatically selected and run. If need it to be executed in 32-bit mode, use command prompt for running it. When you install 64-bit Integration Services, it installs both 32-bit and 64-bit. As command prompt uses PATH environment variable for finding directories, and 32-bit version path (C:\Program Files(x86)\....) appears before 64-bit version path, it uses 32-bit dtexec for executing packages. &lt;/p&gt;  &lt;p align="justify"&gt;If the package needs to be scheduled with SQL Agent and run in 32-bit mode, that has to be specifically instructed as SQL Agent uses 64-bit version without using PATH environment variable. It can be done by setting &lt;b&gt;Use 32 bit runtime&lt;/b&gt; on the &lt;b&gt;Execution Options&lt;/b&gt; of the &lt;b&gt;Job Step.&lt;/b&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-5891956696943549832?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/5891956696943549832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=5891956696943549832&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5891956696943549832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5891956696943549832'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/07/script-task-cannot-be-debugged.html' title='Script Task cannot be debugged: Integration Services'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/-A_JrvcPfnjk/ThE6205lgoI/AAAAAAAAA2w/oEHRJ1_OXYU/s72-c/image_thumb%25255B1%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-4051690866773992596</id><published>2011-05-15T18:33:00.001-07:00</published><updated>2011-05-15T18:33:04.236-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Business Intelligence'/><title type='text'>How the term “Business Intelligence” is born?</title><content type='html'>&lt;p align="justify"&gt;This is not about processes or usage of Business Intelligence solutions, it is about usage of this term. Unfortunately it looks like this is unknown to many (Unawareness for this is reasonable but I can remember that when a picture of Charles Babbage is shown at a session, many did not recognize or aware of him).&lt;/p&gt;  &lt;p align="justify"&gt;The term “Business Intelligence” firstly appeared in 1958. It was used by a IBM researcher, &lt;a href="http://en.wikipedia.org/wiki/Hans_Peter_Luhn" target="_blank"&gt;Hans Peter Luhn&lt;/a&gt;, in one of his articles. His definition for it was;&lt;/p&gt;  &lt;p align="justify"&gt;“&lt;strong&gt;&lt;em&gt;The ability to apprehend the interrelationships of presented facts in such a way as to guide action towards a desired goal&lt;/em&gt;&lt;/strong&gt;”&lt;/p&gt;  &lt;p align="justify"&gt;Although Hans introduced (or used) this word for processes related to business intelligence, it was not a widespread term until late 1990s. It was the time for Decision Support Systems. In 1989, Howard Dresner proposed “Business Intelligence” as an umbrella term but it looks like the real usage of the term started in 1996. Later Howard became an Analyst for &lt;a href="http://en.wikipedia.org/wiki/Gartner_Group" target="_blank"&gt;Gartner Group&lt;/a&gt;, and it is &lt;a href="http://en.wikipedia.org/wiki/Gartner_Group" target="_blank"&gt;Gartner Group&lt;/a&gt; (&lt;a href="http://www.gartner.com/technology/home.jsp" target="_blank"&gt;Gartner, Inc.&lt;/a&gt;) who labeled this on collective technology used for DSSs. This is how it was published;&lt;/p&gt;  &lt;p&gt;“&lt;strong&gt;&lt;em&gt;Data analysis, reporting, and query tools can help business users wade through a sea of data to synthesize valuable information from it—today these tools collectively fall into a category called ‘Business Intelligence.’&lt;/em&gt;&lt;/strong&gt;”&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-4051690866773992596?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/4051690866773992596/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=4051690866773992596&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4051690866773992596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4051690866773992596'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/05/how-term-business-intelligence-is-born.html' title='How the term “Business Intelligence” is born?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-7048685002669024794</id><published>2011-05-12T10:33:00.000-07:00</published><updated>2011-05-13T13:28:44.237-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Business Intelligence'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='PerformancePoint'/><title type='text'>PerformancePoint web-parts cannot be connected (linked)</title><content type='html'>&lt;p align="justify"&gt;Few days back, I faced for a strange issue with PerformancePoint web-parts. It was a simple thing, all I had was, a web page created with SharePoint and couple of web-parts. Once the page is open in design mode and web-parts are placed, tried to link two web-parts (a report web-part and a filter) through a connection as below;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TcwZ5TshyOI/AAAAAAAAA2E/oxL_YZwtYEU/s1600-h/1%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="1" border="0" alt="1" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TcwZ67Wu67I/AAAAAAAAA2I/Vb5WIwXGVxc/1_thumb%5B1%5D.png?imgmax=800" width="400" height="200" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TcwZ71V9GjI/AAAAAAAAA2M/oRCNTlrJqCY/s1600-h/2%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="2" border="0" alt="2" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TcwZ9AQqD_I/AAAAAAAAA2Q/eRBQ52vsE4U/2_thumb%5B1%5D.png?imgmax=800" width="302" height="313" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Funny thing was, though it allowed me to create the connection (link) and save, it did not get saved permanently. If I open the connection window again, the created connection is missing.&lt;/p&gt;  &lt;p align="justify"&gt;I could not find the issue immediately but it was a terrible thing. Thanks for my colleagues, they have found the issue. It is with Internet Explorer. If you try to do this with Internet Explorer 8.x, it is not going to work. For some of my colleagues, older versions of IE have been worked. For some, older version of FireFox has been worked. Finally what I did was, installed FireFox 3.6 and got it done. Note that it is not going to work with FireFox 4.x too.&lt;/p&gt;  &lt;p align="justify"&gt;Anyone faced this issue? Why SharePoint gives an issue with latest browsers? If you know anything on this, please share with me.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-7048685002669024794?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/7048685002669024794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=7048685002669024794&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7048685002669024794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7048685002669024794'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/05/performancepoint-web-parts-cannot-be.html' title='PerformancePoint web-parts cannot be connected (linked)'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_p0AH7nWLB-k/TcwZ67Wu67I/AAAAAAAAA2I/Vb5WIwXGVxc/s72-c/1_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-2008209208846049675</id><published>2011-05-01T20:16:00.001-07:00</published><updated>2011-05-01T20:16:52.802-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Object Name Resolution – SQL Server</title><content type='html'>&lt;p align="justify"&gt;Understanding how SQL Server resolves objects’ names will be an effective remedy against performance issues. This name resolution happens if securables are not fully qualified. A statement like &lt;strong&gt;SELECT SalesOrderID FROM SalesOrderHeader&lt;/strong&gt; will be a candidate for this. As you see, the &lt;strong&gt;SalesOrderHeader&lt;/strong&gt; is not written as a fully qualified name, hence SQL Server tries to resolve it by adding &lt;strong&gt;Schema&lt;/strong&gt; owned by user connected. If SQL Server cannot find an object like &lt;strong&gt;&lt;em&gt;ConnectedUser’sSchema.SalesOrderHeader&lt;/em&gt;&lt;/strong&gt; then it tries to find an object called &lt;strong&gt;&lt;em&gt;dbo.SalesOrderHeader&lt;/em&gt;&lt;/strong&gt; as the second step. Error is thrown, if it is not successful too. Here is an example for it;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;USE&lt;/span&gt; AdventureWorks2008&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- creating a new table with dbo schema&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TOP&lt;/span&gt; (1) * &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; SalesOrderHeader&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.SalesOrderHeader&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Create two logins for testing&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; LOGIN HR_Manager &lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; PASSWORD = &lt;span style="color: #006080"&gt;'123'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , CHECK_POLICY = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; LOGIN Sales_Manager &lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; PASSWORD = &lt;span style="color: #006080"&gt;'123'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , CHECK_POLICY = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Adding them as users with default schemas&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; HR_Manager &lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; DEFAULT_SCHEMA = HumanResources&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; Sales_Manager &lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; DEFAULT_SCHEMA = Sales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Given users permission on data reading&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;sp_addrolemember &lt;span style="color: #006080"&gt;'db_datareader'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'HR_Manager'&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;sp_addrolemember &lt;span style="color: #006080"&gt;'db_datareader'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Sales_Manager'&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Execute as HT_Manager and see&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; = &lt;span style="color: #006080"&gt;'HR_Manager'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- This shows records from newly created&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- table, not from original table&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; SalesOrderHeader&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- This throws an error&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; SalesOrderDetail&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;REVERT&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Execute as Sales_Manager&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; = &lt;span style="color: #006080"&gt;'Sales_Manager'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Both statements will work&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; SalesOrderHeader&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; SalesOrderDetail&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;REVERT&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;As you see with the code, when &lt;strong&gt;HR_Manager&lt;/strong&gt; executes &lt;strong&gt;&lt;em&gt;SELECT&lt;/em&gt;&lt;/strong&gt; statements, as the first step, names of them will be resolved as &lt;strong&gt;&lt;em&gt;HumanResources.SalesOrderHeader&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;HumanResources.SalesOrderDetail&lt;/em&gt;&lt;/strong&gt;. SQL Server does not find any objects and do the next step, resulting &lt;strong&gt;&lt;em&gt;dbo.SalesOrderHeader&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;dbo.SalesOrderDetail&lt;/em&gt;&lt;/strong&gt;. A match will be found for first one as we have created one with &lt;strong&gt;&lt;em&gt;dbo &lt;/em&gt;&lt;/strong&gt;schema but not for the second. In that case, second statement throws an error.&lt;/p&gt;

&lt;p align="justify"&gt;When &lt;strong&gt;Sales_Manager &lt;/strong&gt;executes, SQL Server resolves objects’ names as &lt;strong&gt;&lt;em&gt;Sales.SalesOrderHeader&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;Sales.SalesOrderDetail&lt;/em&gt;&lt;/strong&gt;. In that case, both statements are successfully executed.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/Tb4iHG09FkI/AAAAAAAAA18/9UgQeUlXz9Y/s1600-h/NameResolution%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="NameResolution" border="0" alt="NameResolution" src="http://lh6.ggpht.com/_p0AH7nWLB-k/Tb4iIhztd0I/AAAAAAAAA2A/52WdVAI2Vik/NameResolution_thumb%5B1%5D.png?imgmax=800" width="403" height="288" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Even though &lt;strong&gt;Sales_Manager&lt;/strong&gt; executes statements without any error, it would be always better to make securables as fully qualified objects, that helps SQL Server to quickly execute the code without performing an additional task.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-2008209208846049675?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/2008209208846049675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=2008209208846049675&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/2008209208846049675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/2008209208846049675'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/05/object-name-resolution-sql-server.html' title='Object Name Resolution – SQL Server'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_p0AH7nWLB-k/Tb4iIhztd0I/AAAAAAAAA2A/52WdVAI2Vik/s72-c/NameResolution_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-7194796604067578385</id><published>2011-04-30T21:33:00.001-07:00</published><updated>2011-04-30T21:33:12.072-07:00</updated><title type='text'>Database Option: CURSOR DEFAULT {LOCAL | GLOBAL} - Is CURSOR Global?</title><content type='html'>&lt;p align="justify"&gt;Setting the value of this option as &lt;strong&gt;GLOBAL&lt;/strong&gt; has been understood wrongly by many developers. All you have to remember is, this “&lt;em&gt;global&lt;/em&gt;” does not refer all &lt;em&gt;connections&lt;/em&gt;, it refers the &lt;em&gt;current connection&lt;/em&gt;. If either database option or at the declaration of cursor, GLOBAL is set, it means that scope of the cursor is global to the connection. Simply it can be referenced in any stored procedure or batch executed by same connection. If LOCAL is used, it is only for the batch which it was created. See the code below;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Parent SP with a cursor&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROC&lt;/span&gt; TestCursorParentSP&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;DECLARE&lt;/span&gt; @SalesOrderID &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;DECLARE&lt;/span&gt; cur &lt;span style="color: #0000ff"&gt;CURSOR&lt;/span&gt; &lt;span style="color: #0000ff"&gt;GLOBAL&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;FOR&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; SalesOrderID &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.SalesOrderHeader &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;OPEN&lt;/span&gt; cur&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;FETCH&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NEXT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; cur &lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; @SalesOrderID&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; @SalesOrderID&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;EXEC&lt;/span&gt; TestCursorChildSP&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;CLOSE&lt;/span&gt; cur&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;DEALLOCATE&lt;/span&gt; cur&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;END&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Child SP that accesses cursor declared by parent&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROC&lt;/span&gt; TestCursorChildSP&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;DECLARE&lt;/span&gt; @SalesOrderID &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;FETCH&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NEXT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; cur &lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; @SalesOrderID&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; @SalesOrderID&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;END&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Executing parent sp&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Get values from both SPs&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXEC&lt;/span&gt; TestCursorParentSP&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;If the cursor is declared as LOCAL, child SP will not be able to access it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-7194796604067578385?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/7194796604067578385/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=7194796604067578385&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7194796604067578385'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7194796604067578385'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/04/database-option-cursor-default-local.html' title='Database Option: CURSOR DEFAULT {LOCAL | GLOBAL} - Is CURSOR Global?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-4197894476653418275</id><published>2011-04-26T17:34:00.001-07:00</published><updated>2011-04-26T17:34:09.880-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft Certifications'/><title type='text'>New Prices for Microsoft Certifications Exams</title><content type='html'>&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/Tbdke5-cRtI/AAAAAAAAA10/72__EHjgfV4/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TbdkgLtP4GI/AAAAAAAAA14/zqoE6KUF7cw/image_thumb%5B1%5D.png?imgmax=800" width="387" height="328" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you plan for doing MS exams, better hurry up. Following certifications are slated for a price increase:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Microsoft Certified Technology Specialist (MCTS)&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Microsoft Certified IT Professional (MCITP)&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Microsoft Certified Professional Developer (MCPD)&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Microsoft Certified Desktop Support Technician (MCDST)&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Microsoft Certified Systems Administrator (MCSA)&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Microsoft Certified Systems Engineer (MCSE)&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Microsoft Certified Application Developer (MCAD)&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Microsoft Certified Solution Developer (MCSD)&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Microsoft Certified Database Administrator (MCDBA)&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;See more detail:   &lt;br /&gt;&lt;a href="http://www.microsoft.com/learning/en/us/certification/cert-pricing-FAQ.aspx"&gt;http://www.microsoft.com/learning/en/us/certification/cert-pricing-FAQ.aspx&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-4197894476653418275?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/4197894476653418275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=4197894476653418275&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4197894476653418275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4197894476653418275'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/04/new-prices-for-microsoft-certifications.html' title='New Prices for Microsoft Certifications Exams'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_p0AH7nWLB-k/TbdkgLtP4GI/AAAAAAAAA14/zqoE6KUF7cw/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-9153101982031272768</id><published>2011-04-24T10:06:00.001-07:00</published><updated>2011-04-24T10:06:42.221-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='TOP'/><title type='text'>TOP WITH TIES: Have you shown your TOP 10 Customers properly?</title><content type='html'>&lt;p align="justify"&gt;Think about a scenario where you have to show your top 10 customers based on their purchases. If the record set is as below;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TbRYhq0R8zI/AAAAAAAAA1k/TCp8cb9ItP8/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TbRYjGp5KyI/AAAAAAAAA1o/p8h7b6x1BU4/image_thumb%5B1%5D.png?imgmax=800" width="383" height="366" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;and if you show first 10 records using &lt;strong&gt;&lt;em&gt;TOP 10&lt;/em&gt;&lt;/strong&gt;, have you shown all best customers? See the 11th record, it is same as 10th order, hence he should be added to top-10 list. In this case, top-10 list becomes top-11 list. But we cannot change the query as &lt;strong&gt;&lt;em&gt;TOP 11&lt;/em&gt;&lt;/strong&gt; because it is not always guaranteed that 11th record is same as 10th record. In that case, what would be the way?&lt;/p&gt;  &lt;p align="justify"&gt;The solution is, &lt;strong&gt;&lt;em&gt;TOP 10 WITH TIES&lt;/em&gt;&lt;/strong&gt;. It adds additional rows to the resultset if any tied rows for 10th are there. See the code below;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_p0AH7nWLB-k/TbRYkBQthII/AAAAAAAAA1s/wRGhzS_kLyk/s1600-h/image%5B7%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TbRYlROF0QI/AAAAAAAAA1w/UjWczQDMQDw/image_thumb%5B3%5D.png?imgmax=800" width="405" height="266" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Note that &lt;strong&gt;&lt;em&gt;WITH TIES&lt;/em&gt;&lt;/strong&gt; can be only used with &lt;strong&gt;&lt;em&gt;SELECT&lt;/em&gt;&lt;/strong&gt; statement and &lt;strong&gt;&lt;em&gt;ORDER BY &lt;/em&gt;&lt;/strong&gt;must be used too.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-9153101982031272768?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/9153101982031272768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=9153101982031272768&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/9153101982031272768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/9153101982031272768'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/04/top-with-ties-have-you-shown-my-top-10.html' title='TOP WITH TIES: Have you shown your TOP 10 Customers properly?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_p0AH7nWLB-k/TbRYjGp5KyI/AAAAAAAAA1o/p8h7b6x1BU4/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-7792092794676378290</id><published>2011-04-23T19:53:00.001-07:00</published><updated>2011-04-23T19:53:33.301-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Service Pack'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008 R2'/><title type='text'>SQL Server 2008 R2 SP1–CTP is available for downloading</title><content type='html'>&lt;p&gt;Microsoft announces the availability of Service Pack 1 as Community Technology Preview for SQL Server 2008 R2. Here are some of enhancements come with SP1;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Dynamic Management Views for increased supportability&lt;/li&gt;    &lt;li&gt;ForceSeek for improved querying performance&lt;/li&gt;    &lt;li&gt;Data-tier Application Component Framework for improved database upgrades&lt;/li&gt;    &lt;li&gt;Disk space control for PowerPivot&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here is the link for downloading: &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=bd200f8e-ba8a-45e3-af59-e28a9e2d17df&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/en/details.aspx?FamilyID=bd200f8e-ba8a-45e3-af59-e28a9e2d17df&amp;amp;displaylang=en&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Note that this is CTP, not for installing in live environment.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-7792092794676378290?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/7792092794676378290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=7792092794676378290&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7792092794676378290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7792092794676378290'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/04/sql-server-2008-r2-sp1ctp-is-available.html' title='SQL Server 2008 R2 SP1–CTP is available for downloading'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-3687212871207674765</id><published>2011-04-21T18:51:00.001-07:00</published><updated>2011-04-21T18:51:26.200-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><title type='text'>Does Referential Integrity improve performance?</title><content type='html'>&lt;p align="justify"&gt;I believe that everybody knows that Referential Integrity is for maintaining the relationship between two entities; Parent and Child. It makes sure that no child records is exist without a parent. Referential Integrity is implemented with Foreign Keys. The foreign key column can be set as Nullable, in that case it allows to have a child without a parent &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TbDexXvEstI/AAAAAAAAA1Q/6bh5DDUkdoE/wlEmoticon-smile%5B2%5D.png?imgmax=800" /&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;While I was going through my one of my old presentations, I found a slide related to this (yes, it is good to keep old presentations, human forgets things). Let me explain it with a code;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TbDe120EyqI/AAAAAAAAA1U/0RGKy_Sx1K8/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TbDe7Dk7AzI/AAAAAAAAA1Y/l5T71O5BuAg/image_thumb%5B1%5D.png?imgmax=800" width="401" height="202" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;The above code is executed against AdventureWorks2008 database. Note that it gets records only from &lt;strong&gt;&lt;em&gt;Detail&lt;/em&gt;&lt;/strong&gt; table even though &lt;strong&gt;&lt;em&gt;Header&lt;/em&gt;&lt;/strong&gt; table is joined. You may say that this join is useless because it does not get data from &lt;strong&gt;&lt;em&gt;Header&lt;/em&gt;&lt;/strong&gt;. True, but see, though we have linked the header to detail, as per the plan, SQL Server does not access the header. It knows that referential integrity is implemented and existence of parent records is guaranteed, hence it does not need to access the header. Now let’s remove the relationship between header and detail, and execute the same.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_p0AH7nWLB-k/TbDe_tdfSYI/AAAAAAAAA1c/nx_XNtGPpo0/s1600-h/image%5B7%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TbDfGM6SU-I/AAAAAAAAA1g/dS7d_qPNCH4/image_thumb%5B3%5D.png?imgmax=800" width="399" height="215" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Query is same but in this case, SQL Server scans the header table. The reason is it does not know whether records are exist in header for every child, it accesses the header though there is no request for values in header. Can you see, referential integrity is not only for making sure that database is consistence, it improves the performance too.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-3687212871207674765?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/3687212871207674765/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=3687212871207674765&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3687212871207674765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3687212871207674765'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/04/does-referential-integrity-improve.html' title='Does Referential Integrity improve performance?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_p0AH7nWLB-k/TbDexXvEstI/AAAAAAAAA1Q/6bh5DDUkdoE/s72-c/wlEmoticon-smile%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-3040833409890922209</id><published>2011-04-17T10:52:00.001-07:00</published><updated>2011-04-17T10:52:12.066-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Dimension'/><category scheme='http://www.blogger.com/atom/ns#' term='Analysis Services'/><category scheme='http://www.blogger.com/atom/ns#' term='Article'/><title type='text'>Ordering Attribute Members of Dimensions in Analysis Services</title><content type='html'>&lt;p align="justify"&gt;As each attribute in a dimension can have a key column and optionally name column, attribute can be sorted by either key or name column. Sorting is done with &lt;em&gt;&lt;strong&gt;OrderBy&lt;/strong&gt; &lt;/em&gt;property. Once the property is set, attribute is sorted in ascending when it is displayed. This is okay with most cases but in some cases sorting is needed in a different way. Examples cane be, sorting in descending order, sorting by not its key or name, by some other attribute. This post discusses these exceptional cases.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font color="#800000"&gt;&lt;strong&gt;Sort by some other attribute&lt;/strong&gt;      &lt;br /&gt;&lt;/font&gt;Good scenario for this is &lt;strong&gt;&lt;em&gt;Month &lt;/em&gt;&lt;/strong&gt;attribute in a &lt;strong&gt;&lt;em&gt;Month &lt;/em&gt;&lt;/strong&gt;dimension. Usually we set &lt;strong&gt;&lt;em&gt;Month&lt;/em&gt;&lt;/strong&gt; attribute’s &lt;strong&gt;&lt;em&gt;Key Column &lt;/em&gt;&lt;/strong&gt;as &lt;em&gt;&lt;strong&gt;MonthKey&lt;/strong&gt;&lt;/em&gt; and its &lt;strong&gt;&lt;em&gt;Name Column &lt;/em&gt;&lt;/strong&gt;as &lt;strong&gt;&lt;em&gt;MonthName&lt;/em&gt;&lt;/strong&gt;. If the sorting is set as &lt;strong&gt;Key&lt;/strong&gt; with &lt;strong&gt;OrderBy&lt;/strong&gt; property, months will be ordered chronologically only if you have inserted them in source table in an order. If they are not inserted in an order, months will not be ordered as we want. Again, if &lt;strong&gt;&lt;em&gt;OrderBy&lt;/em&gt;&lt;/strong&gt; property is set as &lt;strong&gt;&lt;em&gt;Name&lt;/em&gt;&lt;/strong&gt;, months will be displayed in alphabetical order which is not the way we usually want. See the image below.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_p0AH7nWLB-k/Tasouav5y-I/AAAAAAAAA1A/7-o_3j4EEwc/s1600-h/Ordering1%5B4%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Ordering1" border="0" alt="Ordering1" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TasowBkdaWI/AAAAAAAAA1E/I6owaxth5hI/Ordering1_thumb%5B2%5D.png?imgmax=800" width="370" height="546" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Note that records are not inserted in an order. &lt;strong&gt;&lt;em&gt;Month&lt;/em&gt;&lt;/strong&gt; attribute’s &lt;strong&gt;&lt;em&gt;key&lt;/em&gt;&lt;/strong&gt; is set with &lt;em&gt;&lt;strong&gt;MonthKey &lt;/strong&gt;&lt;/em&gt;and its &lt;strong&gt;&lt;em&gt;name&lt;/em&gt;&lt;/strong&gt; is set with &lt;strong&gt;&lt;em&gt;MonthNameWithYear&lt;/em&gt;&lt;/strong&gt;. You can see how they are displayed with &lt;strong&gt;&lt;em&gt;OrderBy&lt;/em&gt;&lt;/strong&gt; set as &lt;strong&gt;&lt;em&gt;key&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;name&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;In order to have the proper ordering on &lt;strong&gt;&lt;em&gt;Month&lt;/em&gt;&lt;/strong&gt; attribute, we need an additional column to be used for sorting. Best candidate is &lt;strong&gt;&lt;em&gt;MonthNumberOfYear&lt;/em&gt;&lt;/strong&gt; column. It can be used as sorting key for &lt;strong&gt;&lt;em&gt;Month&lt;/em&gt;&lt;/strong&gt;. One requirement for doing this is, have a relationship between Month and &lt;strong&gt;&lt;em&gt;MonthNumberOfYear&lt;/em&gt;&lt;/strong&gt;, in other words, making &lt;strong&gt;&lt;em&gt;MonthNumberOfYear&lt;/em&gt;&lt;/strong&gt; as &lt;strong&gt;&lt;em&gt;Related Attribute&lt;/em&gt;&lt;/strong&gt; for &lt;strong&gt;&lt;em&gt;Month&lt;/em&gt;&lt;/strong&gt;. By default, when the dimension is created, wizard adds all the dimension’s attributes as related attributes of the key. In this case, it has been added too. If not, you need to manually add this through &lt;strong&gt;&lt;em&gt;Attribute Relationships&lt;/em&gt;&lt;/strong&gt; (a tab) in BIDS’s Dimension designer. &lt;/p&gt;  &lt;p align="justify"&gt;Once the column is set as a related attribute, change the &lt;strong&gt;&lt;em&gt;OrderBy&lt;/em&gt;&lt;/strong&gt; to &lt;strong&gt;&lt;em&gt;AttributeKey&lt;/em&gt;&lt;/strong&gt; and set &lt;strong&gt;&lt;em&gt;OrderByAttribute&lt;/em&gt;&lt;/strong&gt; as &lt;strong&gt;&lt;em&gt;MonthNumberOfYear. &lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TasoxJcnq4I/AAAAAAAAA1I/wH6ttcxu5pg/s1600-h/Ordering2%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Ordering2" border="0" alt="Ordering2" src="http://lh6.ggpht.com/_p0AH7nWLB-k/Tasoyen5DgI/AAAAAAAAA1M/tF-poYkT_3Y/Ordering2_thumb%5B1%5D.png?imgmax=800" width="345" height="334" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Once processed, months will be displayed in an order as we want. There are two things to be considered in this setting. If &lt;strong&gt;&lt;em&gt;MonthNumberOfYear &lt;/em&gt;&lt;/strong&gt;column is not required for querying, you can hide it by setting AttributeHierarchyEnabled property to false. Other thing is, &lt;strong&gt;&lt;em&gt;Relationship Type&lt;/em&gt;&lt;/strong&gt; between an attribute and related attribute. It can be set as either &lt;strong&gt;&lt;em&gt;Rigid&lt;/em&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;em&gt;Flexible&lt;/em&gt;&lt;/strong&gt;. If the relationship is fixed over time, not going to change (Type 2), &lt;strong&gt;rigid &lt;/strong&gt;is the best option. If the relationship can change over time (Type 1), type has to be set as &lt;strong&gt;&lt;em&gt;Flexible&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Descending Order&lt;/font&gt;&lt;/strong&gt;    &lt;br /&gt;Once the sorting is set for an attribute, it is sorted in ascending order. That is the only possible sorting order supported by Analysis Services. If descending order is required, just like the previous one, support is needed from another attribute that maintains value in descending order. For example, if months need to be sorted in descending, MonthNumberOfYear has to be filled with values 12 to 1, not 1 to 12.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-3040833409890922209?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/3040833409890922209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=3040833409890922209&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3040833409890922209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3040833409890922209'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/04/ordering-attribute-members-of.html' title='Ordering Attribute Members of Dimensions in Analysis Services'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_p0AH7nWLB-k/TasowBkdaWI/AAAAAAAAA1E/I6owaxth5hI/s72-c/Ordering1_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-7032838515796063167</id><published>2011-04-12T21:37:00.001-07:00</published><updated>2011-04-12T21:37:31.264-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><title type='text'>Logical Query Processing Phases in SELECT statement</title><content type='html'>&lt;p align="justify"&gt;The SELECT statement can be constructed with various clauses as per the requirement. It can be as simple as just a set of columns from a table or as complex as a set columns from multiple tables with aggregate functions. Understanding how SQL Server executes added statements will be worthwhile for constructing the SELECT quickly and correctly as per the requirement. Here is the logical processing order in SELECT statement;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TaUoeCWmBNI/AAAAAAAAA0w/D2oAdN1d9D8/s1600-h/Order%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Order" border="0" alt="Order" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TaUof7iv0_I/AAAAAAAAA00/OP6XfTIOvMw/Order_thumb%5B1%5D.png?imgmax=800" width="388" height="166" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Note that all clauses have not been used with above code. Here is the order of all possible phases;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_p0AH7nWLB-k/TaUogw_5mDI/AAAAAAAAA04/4Xfj_V8XDKU/s1600-h/Order2%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Order2" border="0" alt="Order2" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TaUoiWpwRXI/AAAAAAAAA08/8nWlG8ALAtw/Order2_thumb%5B1%5D.png?imgmax=800" width="385" height="185" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;As you see, it is not the order we have written the query, hence keeping this order in mind is absolutely helpful. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-7032838515796063167?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/7032838515796063167/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=7032838515796063167&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7032838515796063167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7032838515796063167'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/04/logical-query-processing-phases-in.html' title='Logical Query Processing Phases in SELECT statement'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_p0AH7nWLB-k/TaUof7iv0_I/AAAAAAAAA00/OP6XfTIOvMw/s72-c/Order_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-4928188332177483865</id><published>2011-03-08T03:53:00.001-08:00</published><updated>2011-03-08T03:53:12.909-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Replication'/><category scheme='http://www.blogger.com/atom/ns#' term='Updatable Subscription'/><title type='text'>SQL Server could not create a subscription for Subscriber: MSDTC on server is unavailable.</title><content type='html'>&lt;p align="justify"&gt;When I configured a subscription for Transactional replication with updatable subscription, the following error occurred.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;em&gt;&lt;font color="#ff0000"&gt;SQL Server could not create a subscription for Subscriber 'DINESH-PC\SQL2008Instance2'. MSDTC on server 'DINESH-PC\SQL2008INSTANCE2' is unavailable.&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p align="justify"&gt;I did not want to set the subscription for &lt;strong&gt;Immediate Updating&lt;/strong&gt; mode, so set to &lt;strong&gt;Queue changes and commit when possible&lt;/strong&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TXYYokqIBAI/AAAAAAAAA0o/2dgehwo4wvI/s1600-h/subscription%5B8%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="subscription" border="0" alt="subscription" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TXYYp4O80YI/AAAAAAAAA0s/S9PHAWTm6V8/subscription_thumb%5B4%5D.png?imgmax=800" width="394" height="363" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;I am aware that MSDTC is used for &lt;strong&gt;Immediate Updating (Simultaneously commit changes)&lt;/strong&gt;. Then why I am getting such error? I did not select that option.&lt;/p&gt;  &lt;p align="justify"&gt;The reason is the wizard. When the subscription is created through the wizard, whatever the selection you make, it makes both &lt;strong&gt;Immediate Updating&lt;/strong&gt; and &lt;strong&gt;Queued Updating&lt;/strong&gt; available for subscription. If you do not want both, do not use the wizard, create the subscription manually using stored procedures. Note that you can use the wizard for generating scripts for the whole task without creating the subscription. The generated script contains four stored procedures;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;sp_addsubscription: This adds a subscription to publication and it has to be run in publisher. You need to make sure that &lt;strong&gt;@update_mode&lt;/strong&gt; is set as ‘&lt;strong&gt;queued tran&lt;/strong&gt;’.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;sp_addpullsubscription: This adds a pull subscription to subscriber, hence needs to run in subscriber. Just like previous one, make sure that &lt;strong&gt;@update_mode&lt;/strong&gt; is set as ‘&lt;strong&gt;queued tran&lt;/strong&gt;’.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;sp_link_publication: This is to use with &lt;strong&gt;Immediate Updating&lt;/strong&gt;, hence you do not need to execute this.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;sp_addpullsubscription_agent: This adds a scheduled agent job to synchronize pull subscription with transactional publication. Run it in subscriber.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Once you run everything, you have a subscription with queued updating mode.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-4928188332177483865?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/4928188332177483865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=4928188332177483865&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4928188332177483865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4928188332177483865'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/03/sql-server-could-not-create.html' title='SQL Server could not create a subscription for Subscriber: MSDTC on server is unavailable.'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_p0AH7nWLB-k/TXYYp4O80YI/AAAAAAAAA0s/S9PHAWTm6V8/s72-c/subscription_thumb%5B4%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-1077580936623834315</id><published>2011-03-07T16:23:00.001-08:00</published><updated>2011-03-07T16:23:27.329-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Replication'/><category scheme='http://www.blogger.com/atom/ns#' term='Article'/><title type='text'>SQL Server Updatable Subscriptions: What is the best replication type for this?</title><content type='html'>&lt;p align="justify"&gt;Replication is used for copying data and database objects from one location to another on a recurring basis. The topology of replication is vary, it can be a simple implementation with two servers or a complex implementation with many local and remote servers and mobile devices. Servers involved are designated with server roles such as Publisher, Distributor and Subscriber and their responsibilities are publishing, distributing, and finally subscribing published data. In some scenarios, subscribers use the subscription only for reading data. In other scenarios subscribers make modification to subscription (change data) and send back to publisher. Such subscriptions are called as Updatable Subscription. SQL Server provides many ways to implement a replication with updatable subscription. This post discusses some considerations and guide lines for selecting the best replication type with updatable subscription suit for your requirement.&lt;/p&gt;  &lt;p align="justify"&gt;The general overview of Replication can be illustrated as below.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TXV2-PwHH-I/AAAAAAAAA0c/6ztJYNpaZIM/s1600-h/Replication3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Replication" border="0" alt="Replication" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TXV2_bjfTDI/AAAAAAAAA0g/vtWo52YLMYc/Replication_thumb1.png?imgmax=800" width="389" height="309" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Publisher: Publishes data with publication.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Distributor: Distributes data. This server holds metadata, historical data and replicated data for some replication types.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Subscriber: Receives data from publications. They can make changes to subscribed data too.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Updatable Subscription&lt;/strong&gt;     &lt;br /&gt;SQL Server provides three different types of Replications. They are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Snapshot replication&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Transactional replication&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Merge replication&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;Changing data at subscriber and sending changes back to publisher facility is not available with all types. Transactional replication and Merge provides facilities for it.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Transactional Replication&lt;/strong&gt; is mainly used in Server-to-Server scenario. Subscribers are initiated with a snapshot of publication and then transactions occurred are sent to them in incremental manner. This replication type allows subscribers to update data and send back to publisher. If it is required, &lt;strong&gt;Transactional Replication with updatable subscription&lt;/strong&gt; option is available at creation of publication. This works in two ways:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;&lt;strong&gt;Immediate Updating&lt;/strong&gt;: Uses MSDTC for sending data from subscribers to publisher and applying. It is done through triggers added in published tables in subscription.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;strong&gt;Queued Updating&lt;/strong&gt;: Changes are sent to a queue. The Queue reader agent pull changes and apply to publisher. It is done with triggers too.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;Read more on these two at: &lt;a title="http://msdn.microsoft.com/en-us/library/ms151794.aspx" href="http://msdn.microsoft.com/en-us/library/ms151794.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms151794.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Now, where we can use &lt;strong&gt;Transactional replication with updatable subscription&lt;/strong&gt;? Here are some guidelines for selecting this as your replication type:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Scenario is Server-to-Server.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Number of subscribers are less than 10.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Subscribers update data infrequently.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Subscribers, distributor and publisher are connected most of the time (For Immediate updating, regular connection is required as update happens synchronously).&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Subscribers need all changes, not the last change (Eg. if there are 100 transactions for a record, all are required by the subscriber, not the final state of the record)&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Expect less update conflicts with queued updating. This type does not have rich facilities for handling conflicts.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;&lt;em&gt;&lt;font color="#ff0000"&gt;**&lt;/font&gt;Note that MSDN says that this feature will be removed in a future version of SQL Server, so it is not advisable to use this if you plan to upgrade your system with future versions.&lt;/em&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Merge replication &lt;/strong&gt;is mainly for Server-to-Client environment. This allows subscribers to make modification on replicated data and send them back to publisher. Use following guidelines when selecting Merge as your replication type for updatable subscription:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Scenario is Server-to-Client.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Many number of updating subscribers (Merge is designed for this).&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Expect conflicts (Good support on conflict detection and resolving)&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Subscribers need the final state of the change, not all transactions.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Subscribers, distributors and publisher are not always connected.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Subscribers need a portion of publication, not the entire one (This is done with dynamic filters in publication).&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;Okay, you can consider given guidelines and select the best type for your requirement. How about Peer-to-Peer replication? Can we use it too for handling this?&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Peer-to-peer replication&lt;/strong&gt; is scale out and high availability solution. It maintains copies of data across multiple servers, referred as nodes. Its foundation is Transactional replication and works in similar manner. The main difference is, nodes are not designated as publisher or subscribers, all are publishers and subscribers. Here are some guidelines for selecting it:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Requires high availability (with other types, if publisher goes down, replication topology is down too).&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Less number of nodes (would be better to have 10 or less).&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Filtering of publication is not required.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Do not expect much conflicts.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-1077580936623834315?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/1077580936623834315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=1077580936623834315&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/1077580936623834315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/1077580936623834315'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/03/sql-server-updatable-subscriptions-what.html' title='SQL Server Updatable Subscriptions: What is the best replication type for this?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_p0AH7nWLB-k/TXV2_bjfTDI/AAAAAAAAA0g/vtWo52YLMYc/s72-c/Replication_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-6640336245634800161</id><published>2011-03-04T00:37:00.001-08:00</published><updated>2011-03-04T00:37:03.484-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Self-Service Business Intelligence'/><title type='text'>Self-Service Business Intelligence with SQL Server 2008 R2 – Speaking engagement in SQL Server Sri Lanka User Group</title><content type='html'>&lt;p&gt;The February meeting of SQL Server Sri Lanka User Group meeting was held on last Wednesday and sessions were done by Dinesh Asanka and me. My session was on Self-Service Business Intelligence with SQL Server 2008 R2, focusing on PowerPivot. The agenda for the sessions was:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;What’s new in SQL Server 2008 R2? &lt;/li&gt;    &lt;li&gt;What is Business Intelligence? &lt;/li&gt;    &lt;li&gt;Introduction to New Paradigm &lt;/li&gt;    &lt;li&gt;Introduction SQL Server PowerPivot &lt;/li&gt;    &lt;li&gt;Future Releases &lt;/li&gt;    &lt;li&gt;Q &amp;amp; A &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The presentation is available for downloading: &lt;a href="http://www.sqlserveruniverse.com/v2/SSSLUG/Downloads.aspx"&gt;http://www.sqlserveruniverse.com/v2/SSSLUG/Downloads.aspx&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-6640336245634800161?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/6640336245634800161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=6640336245634800161&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/6640336245634800161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/6640336245634800161'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/03/self-service-business-intelligence-with.html' title='Self-Service Business Intelligence with SQL Server 2008 R2 – Speaking engagement in SQL Server Sri Lanka User Group'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-290854323407746401</id><published>2011-02-20T19:46:00.001-08:00</published><updated>2011-02-20T19:46:50.701-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Guest user account</title><content type='html'>&lt;p align="justify"&gt;The Guest user is an account which is automatically created when a database is created. This account is used when a login connects to a database without having a user account created in it. By default, guest is disabled, to enable and disable, use the codes below;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- to enable&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GRANT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;CONNECT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TO&lt;/span&gt; GUEST&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- to disable&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;REVOKE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;CONNECT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; GUEST&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;The recommended way of managing guest account is, have it in disabled status. If you have enabled it for some reason, permission can be granted either using graphical interface or through T-SQL.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Give data read permission to guest on Customer table&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GRANT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; Sales.Customer &lt;span style="color: #0000ff"&gt;TO&lt;/span&gt; GUEST&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;If guest is enabled in AdventureWorks2008 database and above permission is granted, when a login (eg. Jane) connects to AdventureWorks2008, she will be able to read data from Sales.Customer though she has no user account created in AdventureWorks2008.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-290854323407746401?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/290854323407746401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=290854323407746401&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/290854323407746401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/290854323407746401'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/02/guest-user-account.html' title='Guest user account'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-1227574743201567985</id><published>2011-02-07T19:49:00.001-08:00</published><updated>2011-02-07T19:49:41.246-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Management Studio'/><title type='text'>Template Explorer in SQL Server</title><content type='html'>&lt;p align="justify"&gt;Although this is not much popular among DBEs, it is one of the facilities should be used. The Template Explorer gives us various type of templates for constructing objects. For an example, if you need to create a database using T-SQL, the template of the &lt;strong&gt;CREATE DATABASE&lt;/strong&gt; can be taken from the Template Explorer and altered as you need. This definitely speeds up coding though it discourages remembering syntax.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TVC9Qmk2tnI/AAAAAAAAA0Q/ZGdT6sydwnA/s1600-h/TE3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="TE" border="0" alt="TE" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TVC9URqgY3I/AAAAAAAAA0U/CX4lazZbeK8/TE_thumb1.png?imgmax=800" width="208" height="360" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;The Template Explorer can be opened using &lt;strong&gt;View –&amp;gt; Template Explorer&lt;/strong&gt; (or &lt;strong&gt;Ctrl+Alt+T&lt;/strong&gt;) menu. Templates are grouped into three: SQL Server, Analysis Server, SQL Server Compact. Templates in a group are categorized too. For an example, if you want to create a database with multiple file groups, &lt;strong&gt;CREATE DATABASE ON MULTIPLE FILEGROUPS&lt;/strong&gt; in &lt;strong&gt;DATABASE&lt;/strong&gt;&amp;#160; category under &lt;strong&gt;SQL SERVER&lt;/strong&gt; group can be used.&lt;/p&gt;  &lt;p align="justify"&gt;Template can be brought into query window by dragging and dropping or double-clicking. Once placed, need to replace parameter values with your values. Although you can manually do it, easiest way is, using &lt;strong&gt;Specify Values for Template Parameters&lt;/strong&gt; window. It can be accessed using &lt;strong&gt;Query –&amp;gt; Specify Values for Template Parameters&lt;/strong&gt; menu.&lt;/p&gt;  &lt;p align="justify"&gt;You can create your own templates and have them in Template Explorer. Start it with creating a folder or add new ones in given folders (categories). This facility is open through right-clicking on the folder in Template Explorer and selecting &lt;strong&gt;New&lt;/strong&gt;. One thing you need to remember is the way of adding parameters. Parameters should be enclosed with “&amp;lt;” and “&amp;gt;” and should contain three parts: Parameter name, type, value. You can have the same for both Parameter name and value, allowing user to replace the “value” with their value. For an example, parameter for database name would be: &amp;lt;Database_Name, sysname, Database_Name&amp;gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-1227574743201567985?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/1227574743201567985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=1227574743201567985&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/1227574743201567985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/1227574743201567985'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/02/template-explorer-in-sql-server.html' title='Template Explorer in SQL Server'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_p0AH7nWLB-k/TVC9URqgY3I/AAAAAAAAA0U/CX4lazZbeK8/s72-c/TE_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-7019579713227449701</id><published>2011-02-06T16:55:00.001-08:00</published><updated>2011-02-06T17:00:57.833-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><title type='text'>sys.database_files: size column and why 128?</title><content type='html'>&lt;p align="justify"&gt;It came up while my class was being conducted. We were discussing of finding the size of files attached to a database and available free space of files. As usual I used my sample codes to show few things, this is one of them:&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; name, &lt;span style="color: #0000ff"&gt;size&lt;/span&gt;/128 &lt;span style="color: #0000ff"&gt;size&lt;/span&gt; &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; sys.database_files&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;Now, why 128? It did not come into my mind immediately &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-confusedsmile" alt="Confused smile" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TU9C8GmetOI/AAAAAAAAA0M/OZVQziKHm4I/wlEmoticon-confusedsmile%5B2%5D.png?imgmax=800" /&gt;. Result of being a designer.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;Size&lt;/strong&gt; column shows current size of the file in 8KB pages. It is the number of pages that have been allocated. So, why 128? It is for converting to MB. There are 128 8KB pages in 1MB. Here is my altered code;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; name, &lt;span style="color: #0000ff"&gt;size&lt;/span&gt;/128 SizeInMB&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , FILEPROPERTY(name, &lt;span style="color: #006080"&gt;'SpaceUsed'&lt;/span&gt;)/128 SpaceUsedInMB &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; sys.database_files&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- or&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; name, &lt;span style="color: #0000ff"&gt;size&lt;/span&gt;*8 SizeInKB&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , FILEPROPERTY(name, &lt;span style="color: #006080"&gt;'SpaceUsed'&lt;/span&gt;)*8 SpaceUsedInKB &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; sys.database_files&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-7019579713227449701?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/7019579713227449701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=7019579713227449701&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7019579713227449701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7019579713227449701'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/02/sysdatabasefiles-size-column-and-why.html' title='sys.database_files: size column and why 128?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_p0AH7nWLB-k/TU9C8GmetOI/AAAAAAAAA0M/OZVQziKHm4I/s72-c/wlEmoticon-confusedsmile%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-3068734129922389436</id><published>2011-02-02T17:17:00.001-08:00</published><updated>2011-02-02T17:17:35.800-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008 R2'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Article'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerPivot'/><title type='text'>Installing and Configuring PowerPivot for SharePoint 2010</title><content type='html'>&lt;p align="justify"&gt;Microsoft PowerPivot is slowly becoming an essential technology for Business Users addressing Self-Service Business Intelligence. It is innovated by Microsoft SQL Server team as a part of Microsoft SQL Server 2008 R2 release and comes in two flavors; PowerPivot for Excel and PowerPivot for SharePoint. I have already written a post on Excel add-in (&lt;a href="http://dinesql.blogspot.com/2010/06/creating-self-service-business.html"&gt;Creating Self-Service Business Intelligence dashboard with PowerPivot – Part I&lt;/a&gt;) which discusses dashboard creation with Excel and PowerPivot. This post discusses about Installing PowerPivot for SharePoint 2010 with following sections;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="left"&gt;Excel and SharePoint&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;Install&lt;font color="#000000"&gt;ing PowerPivot for SharePoint 2010&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font color="#000000"&gt;Error: Could not load assembly          &lt;br /&gt;‘Microsoft.AnalysisServices.SharePoint.Integration.dll’ &lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font color="#000000" size="2"&gt;SQL Server Analysis Services Installation – VertiPaq&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font color="#000000"&gt;Deploying PowerPivot solution packages to Web Application&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font color="#000000"&gt;Other Services required&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font color="#000000"&gt;Creating PowerPivot Service Application&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font color="#000000"&gt;PowerPivot Feature Integration for Site Collections&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;Configuring PowerPivotUnAttendedAccount for Data Refresh&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Excel and SharePoint&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;Why two technologies? We can consider that Excel is for authoring PowerPivot applications. It allows to create an application with one or many data sources and then facilitates data analysis in a multi-dimensional structure. It does not need a constant connection to used data sources, everything will be stored inside Excel Workbook and if want, data can be refreshed. SharePoint can be considered as a hosting environment for PowerPivot applications. We usually go for SharePoint if collaboration, sharing and reporting are required.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Installing PowerPivot for SharePoint 2010        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;There are two components need to be installed. PowerPivot System Service and Analysis Services in VertiPaq mode which is a local, in-process Analysis Services engine. Let’s start with Analysis Services.&lt;/p&gt;  &lt;p align="justify"&gt;Installing Analysis Services for PowerPivot is straight forward. I have already set up my SharePoint 2010 farm. It uses SQL Server 2008 R2 that exist in same box. Note that my installation contains full SQL Server product suite, including SQL Server Analysis Services, hence new instance of Analysis Services for PowerPivot will be a named instance. There is a known issue you might face if SQL Server installation is already exist. It is;&lt;/p&gt;  &lt;p align="left"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Could not load assembly ‘Microsoft.AnalysisServices.SharePoint.Integration.dll’&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;You get this error if you have a prior installation of SQL Server 2008 R2. Unfortunately it comes at the completion of the installation. &lt;/p&gt;  &lt;p align="left"&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TUn_dHQxWzI/AAAAAAAAAyM/En9O0U1MH1c/s1600-h/error3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="error" border="0" alt="error" src="https://lh6.googleusercontent.com/_p0AH7nWLB-k/TUn_ktmSygI/AAAAAAAAAyQ/7qIBrOlXFwA/error_thumb1.png?imgmax=800" width="404" height="311" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="left"&gt;Solution for this is simple. Create a text file as below and save it as Setup100.exe.config.    &lt;br /&gt;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #800000"&gt;xml&lt;/span&gt; &lt;span style="color: #ff0000"&gt;version&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;configuration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;runtime&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;disableCachingBindingFailures&lt;/span&gt; &lt;span style="color: #ff0000"&gt;enabled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;runtime&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;configuration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;br /&gt;

&lt;p align="justify"&gt;Then move the file into &lt;u&gt;%ProgramFIles%\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2\x64&lt;/u&gt;. Once the file is placed, you need to start the installation again. For more information, see this: &lt;a href="http://support.microsoft.com/kb/2261507"&gt;http://support.microsoft.com/kb/2261507&lt;/a&gt; .&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000" size="2"&gt;SQL Server Analysis Services Installation – VertiPaq&lt;/font&gt; 

    &lt;br /&gt;&lt;/strong&gt;Before starting the installation, make sure that a domain account is created for new Analysis Services instance for running the service. In my case, newly created account for this is &lt;strong&gt;PowerPivotAnalysisServices&lt;/strong&gt;.&lt;/p&gt;

&lt;p align="justify"&gt;Now run the SQL Server 2008 R2 setup. It would be better to run the setup as &lt;strong&gt;Administrator (Right click on Setup.exe and select “Run as Administrator”)&lt;/strong&gt;. If you have configured more than one server for the farm as Application Servers, the installation should be done for all servers (Generally we set up two servers one for WFE and another for applications. This installation should be done only on Application Servers). &lt;/p&gt;

&lt;p align="justify"&gt;Once the installation is started, select &lt;strong&gt;New installation or add shared features&lt;/strong&gt; as per the screen below. &lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TUn_p4JncFI/AAAAAAAAAyU/e6hyWRVb4eo/s1600-h/14.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="1" border="0" alt="1" src="https://lh3.googleusercontent.com/_p0AH7nWLB-k/TUn_yNLJEfI/AAAAAAAAAyY/Y_4Jucn0yjk/1_thumb1.png?imgmax=800" width="395" height="304" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Continue with screens until you get a screen which allows you to select &lt;strong&gt;SQL Server PowerPivot for SharePoint&lt;/strong&gt;. Select &lt;strong&gt;Existing Farm&lt;/strong&gt; for &lt;strong&gt;Add PowerPivot for SharePoint to &lt;/strong&gt;(Note that assumption here is Farm is already configured).&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TUn_6AeLKUI/AAAAAAAAAyc/CvZIx0Wo8kQ/s1600-h/35.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="3" border="0" alt="3" src="https://lh4.googleusercontent.com/_p0AH7nWLB-k/TUn_8KKaQEI/AAAAAAAAAyg/ZWje9Sptrrw/3_thumb3.png?imgmax=800" width="390" height="309" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Next screen is &lt;strong&gt;Feature Selection&lt;/strong&gt;. It is a read-only screen, you will not be able to change anything on it. Continue with the wizard until you get &lt;strong&gt;Instance Configuration&lt;/strong&gt; screen. You will notice that the instance has already been named ad &lt;strong&gt;POWERPIVOT&lt;/strong&gt;. Do not change it, continue the wizard.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TUn_9qJY5fI/AAAAAAAAAyk/sVJiTWXSfKI/s1600-h/63.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="6" border="0" alt="6" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TUn__C5SzPI/AAAAAAAAAyo/6HlOD1bJS5w/6_thumb1.png?imgmax=800" width="385" height="296" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;At the &lt;strong&gt;Server Configuration &lt;/strong&gt;screen, set newly created domain account and its password for &lt;strong&gt;SQL Server Analysis Services&lt;/strong&gt;. When you have &lt;strong&gt;Analysis Services Configuration &lt;/strong&gt;screen, make sure that accounts that need to be administrators for Analysis Services are added.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TUoADpeSiBI/AAAAAAAAAys/hKN7Pyhg5LI/s1600-h/103.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="10" border="0" alt="10" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TUoAHrGuZLI/AAAAAAAAAyw/sW4HdCRHIM4/10_thumb1.png?imgmax=800" width="384" height="295" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Everything is set now, continue the wizard and complete the installation. Once it is done, go to &lt;strong&gt;SharePoint Central Administration –&amp;gt; System Settings –&amp;gt; Manage Servers in this Farm&lt;/strong&gt;. It shows all the servers in the farm and services running. If you see &lt;strong&gt;SQL Server Analysis Services&lt;/strong&gt; and &lt;strong&gt;SQL Server PowerPivot System Service&lt;/strong&gt;, your installation is successful.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Deploying PowerPivot solution packages to Web Application&lt;/font&gt;&lt;/strong&gt; 

  &lt;br /&gt;Next part is deploying PowerPivot solution packages to Web Applications (to WFE Servers). There are two solution packages. Installation we performed earlier deploys solution packages for Central Administration but not for our web application. Go to &lt;strong&gt;SharePoint Central Administration –&amp;gt; System Settings –&amp;gt; Farm Management –&amp;gt; Manage Farm Solutions&lt;/strong&gt;. You should see two solutions;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;powerpivotfarm.wsp is deployed globally, no need to deploy again.&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;powerpivotwebapp.wsp, you can see that it has been deployed to my default web application (&lt;a href="http://w2008r2-sp:10000"&gt;http://w2008r2-sp:10000&lt;/a&gt;). This is the solution we need to deploy manually to Web Application which suppose to hold PowerPivot data. &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;a href="https://lh6.googleusercontent.com/_p0AH7nWLB-k/TUoAMCk3tmI/AAAAAAAAAy0/4VkJjEuxaXI/s1600-h/p17.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="p1" border="0" alt="p1" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TUoAStcbc6I/AAAAAAAAAy4/7IqDfM959ig/p1_thumb3.png?imgmax=800" width="403" height="293" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Let’s deploy powerpivotwebapp.wsp to a web application. Click on &lt;strong&gt;powerpivotwebapp.wsp&lt;/strong&gt;. It opens &lt;strong&gt;Solution Properties&lt;/strong&gt;. Click on &lt;strong&gt;Deploy Solution&lt;/strong&gt;. Select the web application from the drop-down you need to use under &lt;strong&gt;Deploy to?&lt;/strong&gt; and click &lt;strong&gt;OK&lt;/strong&gt;. Once the &lt;strong&gt;Solution Properties&lt;/strong&gt; page is open, make sure that added web application is listed as below.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_p0AH7nWLB-k/TUoAZ3tIauI/AAAAAAAAAy8/x11jd5ZuJu8/s1600-h/p33.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="p3" border="0" alt="p3" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TUoAgt-y7cI/AAAAAAAAAzA/X3cOkyu1Hqc/p3_thumb1.png?imgmax=800" width="403" height="237" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Other Services required&lt;/font&gt;&lt;/strong&gt; 

  &lt;br /&gt;Next step is starting all other necessary services required by PowerPivot. Make sure following services are running;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;Excel Calculation Service&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;Secure Store Service&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;Claims to Windows token Service&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;SQL Server Analysis Services&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;SQL Server PowerPivot System Service&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;/p&gt;

&lt;p align="justify"&gt;These services are listed under &lt;strong&gt;SharePoint Central Administration –&amp;gt; System Settings –&amp;gt; Manage Services on Servers&lt;/strong&gt;.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Creating PowerPivot Service Application&lt;/font&gt;&lt;/strong&gt; 

  &lt;br /&gt;This helps to establish the communication between WFE and PowerPivot service via PowerPivot Service Application Proxy. Let’s create it. Go to &lt;strong&gt;SharePoint Central Administration –&amp;gt; Application Management –&amp;gt; Manage Service Applications&lt;/strong&gt;. Click on &lt;strong&gt;New&lt;/strong&gt; and select &lt;strong&gt;SQL Server PowerPivot Service Application&lt;/strong&gt;. &lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="https://lh4.googleusercontent.com/_p0AH7nWLB-k/TUoAkUI8zhI/AAAAAAAAAzE/0x9MIpWzpys/s1600-h/p012.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="p01" border="0" alt="p01" src="https://lh5.googleusercontent.com/_p0AH7nWLB-k/TUoAqZDRJoI/AAAAAAAAAzI/TIkTVaGekHs/p01_thumb.png?imgmax=800" width="191" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;With &lt;strong&gt;Create New PowerPivot Service Application &lt;/strong&gt;window, set the name as &lt;strong&gt;PowerPivotServiceApplication&lt;/strong&gt;. Do not use any existing pool, create a new one and assign a domain account for it. Set the database server and database name then. Finally select the checkbox &lt;strong&gt;Add the proxy for this PowerPivot service application to the default proxy group&lt;/strong&gt;. Click &lt;strong&gt;OK&lt;/strong&gt; to create it.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;PowerPivot Feature Integration for Site Collections&lt;/font&gt;&lt;/strong&gt; 

  &lt;br /&gt;This is appeared under &lt;strong&gt;Site Collection Features&lt;/strong&gt; and must be activated for each of the site collections. Go to your site collection and click on &lt;strong&gt;Site Actions –&amp;gt; Site Settings –&amp;gt; Site Collection Administration –&amp;gt; Site Collection Features&lt;/strong&gt;. When the page open, find &lt;strong&gt;PowerPivot Services feature integration for Site Collections&lt;/strong&gt; and activate it.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Configuring PowerPivotUnAttendedAccount for Data Refresh&lt;/font&gt;&lt;/strong&gt; 

  &lt;br /&gt;PowerPivot unattended account is used for refreshing data in the workbook if user credentials are not exist with the workbook. This account is stored in SharePoint Secure Store Service. In order to continue, you need to make sure that Secure Store Service is up and running, and master key is created. I have already configured Secure Store Service for PerformancePoint. If you have not, see this post for configuring it: &lt;a href="http://dinesql.blogspot.com/2010/07/configuring-performancepoint-2010.html"&gt;http://dinesql.blogspot.com/2010/07/configuring-performancepoint-2010.html&lt;/a&gt;.&lt;/p&gt;

&lt;p align="justify"&gt;Let’s open the Secure Store Service Application. Go to &lt;strong&gt;SharePoint Central Administration –&amp;gt; Application Management –&amp;gt; Manage Service Applications&lt;/strong&gt;. Click on &lt;strong&gt;Secure Store Service&lt;/strong&gt; (or select it and click on &lt;strong&gt;Manage&lt;/strong&gt;) link;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TUoAu5tCOTI/AAAAAAAAAzQ/crLdKPbtN1E/s1600-h/p023.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="p02" border="0" alt="p02" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TUoA2IXrSeI/AAAAAAAAAzU/6y-K41beZ7s/p02_thumb1.png?imgmax=800" width="407" height="261" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Secure Store Service uses &lt;strong&gt;Target Applications &lt;/strong&gt;for holding accounts. In my case, I have an application set up for PerformancePoint and that is what has been listed. If you have note, nothing will be listed. Once a Target Application is created for PowerPivot, it has to be associated with PowerPivot Service Application. Let’s start creating the Target Application. Click on &lt;strong&gt;New&lt;/strong&gt; for opening &lt;strong&gt;Create New Secure Store Target Application&lt;/strong&gt;. Set ID and name for the application. Appropriate ID and name would be &lt;strong&gt;PowerPivotDataRefresh&lt;/strong&gt; and &lt;strong&gt;Power Pivot Data Refresh&lt;/strong&gt;. Enter a valid email for &lt;strong&gt;Contact Email&lt;/strong&gt; and select &lt;strong&gt;Individual&lt;/strong&gt; for &lt;strong&gt;Target Application Type&lt;/strong&gt;.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_p0AH7nWLB-k/TUoA9PnXAqI/AAAAAAAAAzY/Vu5cAeeMNGI/s1600-h/p43.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="p4" border="0" alt="p4" src="https://lh4.googleusercontent.com/_p0AH7nWLB-k/TUoBDtMbk6I/AAAAAAAAAzc/IA-T2IKBFSY/p4_thumb1.png?imgmax=800" width="410" height="276" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Next screen for specifying fields (columns) for the application. Accept the default as we need only user name and password and continue.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="https://lh4.googleusercontent.com/_p0AH7nWLB-k/TUoBKqXXAJI/AAAAAAAAAzk/qlEdkT6zWpY/s1600-h/p53.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="p5" border="0" alt="p5" src="https://lh6.googleusercontent.com/_p0AH7nWLB-k/TUoBQPw3tmI/AAAAAAAAAzo/pXgjm4OfizA/p5_thumb1.png?imgmax=800" width="403" height="194" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Next screen for setting admins for the application. Make sure that you have added the account which is used for PowerPivot Service Application pool. In addition to that, any account need to be an admin can be added. Continue the wizard and complete. Finally you are back on Secure Store Service. You should see the newly created application listed now.&lt;/p&gt;

&lt;p align="justify"&gt;Next is setting credentials for PowerPivotDataRefresh application (or PowerPivot unattended account). Select the check box next to newly created application and click on &lt;strong&gt;Set Credentials&lt;/strong&gt; button. It opens the &lt;strong&gt;Set Credentials for Secure Target Application (Individual)&lt;/strong&gt;. Settings for this screen will be;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;Credential Owner: This is the owner of the credential. It will be used by PowerPivot unattended account but &lt;u&gt;this is not the account used as the unattended account&lt;/u&gt;. &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;Windows user name and password: This is the actual account used as the unattended account.&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;a href="https://lh5.googleusercontent.com/_p0AH7nWLB-k/TUoBUr64JDI/AAAAAAAAAzs/mMtDK3GnSrQ/s1600-h/p83.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="p8" border="0" alt="p8" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TUoBccBjsnI/AAAAAAAAAzw/U9ztKE8bW6g/p8_thumb1.png?imgmax=800" width="410" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Click &lt;strong&gt;OK&lt;/strong&gt;. Now we need to associate the application with PowerPivot Service Application. Go to &lt;strong&gt;SharePoint Central Administration –&amp;gt; Application Management –&amp;gt; Manage Service Applications&lt;/strong&gt;. Find PowerPivot Service Application and click the link (or select it and click on &lt;strong&gt;Manage &lt;/strong&gt;button). This opens &lt;strong&gt;PowerPivot Management Dashboard&lt;/strong&gt;. Click on &lt;strong&gt;Configure Service Application Settings&lt;/strong&gt; in &lt;strong&gt;Actions&lt;/strong&gt; frame. It opens &lt;strong&gt;PowerPivot Settings&lt;/strong&gt;. Find &lt;strong&gt;PowerPivot Unattended Data Refresh Account&lt;/strong&gt; input box under &lt;strong&gt;Data Refresh&lt;/strong&gt;. Type the ID of the application created in Secure Store Service, in my case, it is &lt;strong&gt;PowerPivotDataRefresh&lt;/strong&gt;. &lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="https://lh5.googleusercontent.com/_p0AH7nWLB-k/TUoBk-73j8I/AAAAAAAAAz0/cr9YspV1z7E/s1600-h/p93.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="p9" border="0" alt="p9" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TUoBq4VlhWI/AAAAAAAAAz4/GNKxSOOv94Y/p9_thumb1.png?imgmax=800" width="400" height="243" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Done. To complete the process, few setting have to be done in Excel Services.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Settings in Excel Services&lt;/font&gt;&lt;/strong&gt; 

  &lt;br /&gt;Go to &lt;strong&gt;SharePoint Central Administration –&amp;gt; Application Management –&amp;gt; Manage Service Applications&lt;/strong&gt;. Find Excel Services Application and open it. It opens &lt;strong&gt;Manage Excel Services Application&lt;/strong&gt;. Click on &lt;strong&gt;Trusted File Locations&lt;/strong&gt;.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TUoByYGoTmI/AAAAAAAAAz8/e8Q2-Hwzahk/s1600-h/p104.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="p10" border="0" alt="p10" src="https://lh3.googleusercontent.com/_p0AH7nWLB-k/TUoB5-wtBwI/AAAAAAAAA0A/CRpnrn1sZfc/p10_thumb2.png?imgmax=800" width="396" height="349" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;You will see that SharePoint has been added as a Trusted Location (Address is http://). In order to access a workbook by both Excel and PowerPivot services, this is required.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="https://lh4.googleusercontent.com/_p0AH7nWLB-k/TUoCAA6lGrI/AAAAAAAAA0E/6ioIOVAv94c/s1600-h/p113.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="p11" border="0" alt="p11" src="https://lh3.googleusercontent.com/_p0AH7nWLB-k/TUoCIsCmHYI/AAAAAAAAA0I/eQyFP_PD5ZE/p11_thumb1.png?imgmax=800" width="400" height="369" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Get the menu of &lt;strong&gt;http://&lt;/strong&gt; and select &lt;strong&gt;Edit&lt;/strong&gt;. Change following items in &lt;strong&gt;Edit Trusted File Location&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;Workbook Properties: Maximum Workbook Size. Set as you want. Note that maximum file size accepted by SharePoint for both Excel and PowerPivot is 2GB.&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;External Data: Select &lt;strong&gt;Trusted data connection libraries and embedded&lt;/strong&gt; under &lt;strong&gt;Allow External Data&lt;/strong&gt;.&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;Click &lt;strong&gt;OK&lt;/strong&gt; to save settings. Now, You should be able to upload an Excel file that contains PowerPivot data into the web application and see.&lt;/p&gt;

&lt;p align="justify"&gt;Will discuss more on this in another post.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-3068734129922389436?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/3068734129922389436/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=3068734129922389436&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3068734129922389436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3068734129922389436'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/02/installing-and-configuring-powerpivot.html' title='Installing and Configuring PowerPivot for SharePoint 2010'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='https://lh6.googleusercontent.com/_p0AH7nWLB-k/TUn_ktmSygI/AAAAAAAAAyQ/7qIBrOlXFwA/s72-c/error_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-8589824223901016809</id><published>2011-01-21T21:25:00.001-08:00</published><updated>2011-01-21T21:25:39.308-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Reporting Services 2008 R2'/><category scheme='http://www.blogger.com/atom/ns#' term='PerformancePoint'/><title type='text'>PPS Reports: Integrating Reporting Services Reports with PerformancePoint 2010 Dashboards</title><content type='html'>&lt;p align="justify"&gt;The success of Business Intelligence solution can be measured with Visualization of data, hence Visualization in proper manner is important. It is handled through many ways, providing easier access for information to business users. One of the key components in Microsoft Business Intelligence suite is PerformancePoint 2010 which supports visualizing data in number of ways. PPS allows business user to interact with data, organize as he wants and change the content as he wants with its reporting features. Some of reporting facilities available with PPS are Reporting Services reports, Analytic charts, grids, and Decomposition trees. This post focuses on Reporting Services reports, basically, how a Reporting Services report can be added to PPS dashboard.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Microsoft Report Viewer 2008&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;In order to use Reporting Services report with PPS Dashboard Designer, you need to make sure that Microsoft Report Viewer is installed in your machine. If not, you may face errors like “&lt;font color="#ff0000"&gt;Unable to connect with Report Server&lt;/font&gt;” or “&lt;font color="#ff0000"&gt;Could not load file or assembly ‘Microsoft.ReportViewer.WinForms’…..&lt;/font&gt;&lt;font color="#000000"&gt;”. &lt;/font&gt;It is available for 2005, 2008 and 2010 now. It looks like PPS Dashboard Designer works only with 2008 (I have 2008 SP1) but you can try 2010 too. Here are links for downloading it:     &lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=cc96c246-61e5-4d9e-bb5f-416d75a1b9ef&amp;amp;displaylang=en" target="_blank"&gt;Microsoft Report Viewer Distributable 2008&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=bb196d5d-76c2-4a0e-9458-267d22b6aac6&amp;amp;displaylang=en" target="_blank"&gt;Microsoft Report Viewer Distributable 2008 SP1&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a941c6b2-64dd-4d03-9ca7-4017a0d164fd&amp;amp;displaylang=en" target="_blank"&gt;Microsoft Report Viewer Distributable 2010&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Getting Started&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;As usual, you have to start with PPS Dashboard Designer. If you have configured Business Intelligence Web Application and site properly with SharePoint 2010, there will a link available for downloading this ClickOnce application (see &lt;a href="http://dinesql.blogspot.com/2010/07/configuring-performancepoint-2010.html"&gt;Configuring PerformancePoint 2010&lt;/a&gt; for more details). Click on &lt;strong&gt;Run Dashboard Designer&lt;/strong&gt; for downloading the designer.     &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TTpqGGmobNI/AAAAAAAAAw4/LAHMmTejbQc/s1600-h/Image13.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Image1" border="0" alt="Image1" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TTpqHY58V8I/AAAAAAAAAw8/IbGoktcUdOs/Image1_thumb1.png?imgmax=800" width="407" height="229" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TTpqIr-ofzI/AAAAAAAAAxA/KRjMtH_2MuI/s1600-h/Image23.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Image2" border="0" alt="Image2" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TTpqKq8rnII/AAAAAAAAAxE/sIiFS0BiBiY/Image2_thumb1.png?imgmax=800" width="407" height="222" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Once open, Save it with a meaningful name. Then select &lt;strong&gt;PerformancePoint Content&lt;/strong&gt; folder in left-pane and go to &lt;strong&gt;Create&lt;/strong&gt; tab in the ribbon. Click on &lt;strong&gt;Reporting Services&lt;/strong&gt;.     &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TTpqLipKU1I/AAAAAAAAAxI/fz6lmq_SB7Y/s1600-h/Image33.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Image3" border="0" alt="Image3" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TTpqNJ4i3BI/AAAAAAAAAxM/u1QbnJyRpPg/Image3_thumb1.png?imgmax=800" width="404" height="182" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Report Setting&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;You need to set few settings in order to have a Reporting Services report in your dashboard.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Server Mode&lt;/strong&gt;: This allows you to set the mode of Reporting Server you are going to connect with. If it is hosted in SharePoint, select &lt;strong&gt;SharePoint Integrated&lt;/strong&gt;, else select &lt;strong&gt;Report Centre&lt;/strong&gt;. In my case, it is SharePoint Integrated mode.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Report Server URL&lt;/strong&gt;: This is the URL of Report Server Web Service which you set of Reporting Services Configuration Manager.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Report URL&lt;/strong&gt;: This is the exact URL of the report. If it is hosted in SharePoint, make sure that you have given the proper URL (including the extension). If you select &lt;strong&gt;Report Centre&lt;/strong&gt;, you will be able to browse the report and set.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Show toolbar, Show Parameters, Show DocMap&lt;/strong&gt;: You can set the visibility of these items. Note that Document map will not be available for all reports. It has to be created with either Report Builder or BIDS.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Zoom&lt;/strong&gt;: Allows you to set the viewing size.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Format&lt;/strong&gt;: Default is HTML 4.0. You can select other types such as Excel or PDF. Based on the type you select, report will be either shown in the web page or will be downloading to client machine.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Section&lt;/strong&gt;: This allows you to set the page to be displayed. If you set 3 for this, 3rd page will be open as the default page.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;DocMap ID&lt;/strong&gt;: It is supposed to show the element set with this as the default page. I could not figure it out the way of setting it, for me, it did not work.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Report Parameters&lt;/strong&gt;: This allows to set parameters default values.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TTpqN4z6KrI/AAAAAAAAAxQ/SfVqZCmJMqg/s1600-h/Image43.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Image4" border="0" alt="Image4" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TTpqPNx7CII/AAAAAAAAAxU/DX_KXFGmG1I/Image4_thumb1.png?imgmax=800" width="405" height="388" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Once settings are done, add a dashboard and place the report, and publish to SharePoint site. SharePoint site can be set with File Button –&amp;gt; Designer Options –&amp;gt; Server –&amp;gt; SharePoint URL. Make sure it is set before publishing.    &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TTpqQZxt70I/AAAAAAAAAxY/bynHHnnZjv8/s1600-h/Image53.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Image5" border="0" alt="Image5" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TTpqRvy7rJI/AAAAAAAAAxc/Q95j0jrY3Q0/Image5_thumb1.png?imgmax=800" width="409" height="262" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Here is the published dashboard.    &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TTpqTPh-jhI/AAAAAAAAAxg/y71dvFLErTI/s1600-h/Image63.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Image6" border="0" alt="Image6" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TTpqUAuDCRI/AAAAAAAAAxk/b6BU2OpNTgc/Image6_thumb1.png?imgmax=800" width="411" height="228" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-8589824223901016809?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/8589824223901016809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=8589824223901016809&amp;isPopup=true' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/8589824223901016809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/8589824223901016809'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/01/pps-reports-integrating-reporting.html' title='PPS Reports: Integrating Reporting Services Reports with PerformancePoint 2010 Dashboards'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_p0AH7nWLB-k/TTpqHY58V8I/AAAAAAAAAw8/IbGoktcUdOs/s72-c/Image1_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-38262696614995332</id><published>2011-01-21T18:54:00.001-08:00</published><updated>2011-01-21T21:22:45.394-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PerformancePoint'/><title type='text'>PerformancePoint 2010: Decomposition Tree is not available</title><content type='html'>&lt;p align="justify"&gt;Are you unable to find the Decomposition Tree in the menu? Is it not visible?    &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TTpG4EsFeQI/AAAAAAAAAww/8x_bH_HfpNg/s1600-h/Image17.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Image1" border="0" alt="Image1" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TTpG5c5E1VI/AAAAAAAAAw0/4JtO6n_KZOc/Image1_thumb3.png?imgmax=800" width="399" height="299" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Reason is simple, make sure &lt;a href="http://www.silverlight.net/getstarted/" target="_blank"&gt;SilverLight 3 (or 4)&lt;/a&gt; is installed. Once it is installed, it will be available for you. Thanks for &lt;a href="http://dinushaonline.blogspot.com/" target="_blank"&gt;Dinusha&lt;/a&gt; for reminding me on this.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-38262696614995332?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/38262696614995332/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=38262696614995332&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/38262696614995332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/38262696614995332'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/01/performancepoint-2010-decomposition.html' title='PerformancePoint 2010: Decomposition Tree is not available'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_p0AH7nWLB-k/TTpG5c5E1VI/AAAAAAAAAw0/4JtO6n_KZOc/s72-c/Image1_thumb3.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-5690516761234051265</id><published>2011-01-20T00:33:00.001-08:00</published><updated>2011-01-20T00:33:47.739-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008 R2'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Reporting Services 2008 R2'/><title type='text'>Configuring Reporting Services 2008 R2 in SharePoint 2010 Integrated Mode – Part III</title><content type='html'>&lt;p align="justify"&gt;Configuring Reporting Services 2008 R2 in SharePoint 2010 Integrated mode is straight forward and simple. If you have read my post &lt;a href="http://dinesql.blogspot.com/2010/06/configuring-reporting-services-2008-r2.html"&gt;Configuring Reporting Services 2008 R2 in SharePoint 2010 Integrated Mode – Part I&lt;/a&gt; and &lt;a href="http://dinesql.blogspot.com/2010/06/configuring-reporting-services-2008-r2_07.html"&gt;Configuring Reporting Services 2008 R2 in SharePoint 2010 Integrated Mode – Part&lt;/a&gt; , then you know the way of configuring it. You will not face much issues after configuring if it is done with Standalone SharePoint 2010 architecture. If it is a SharePoint farm which components are distributed, few things should be considered. Here are some of points you need to consider when Reporting Services is configured in SharePoint 2010 Farm. Note that this was tested with a Web Application which &lt;strong&gt;Authentication&lt;/strong&gt; is set as &lt;strong&gt;Classic&lt;/strong&gt; and &lt;strong&gt;NTLM&lt;/strong&gt; is set for &lt;strong&gt;Authentication Provider&lt;/strong&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Domain accounts created&lt;/font&gt;&lt;/strong&gt;    &lt;br /&gt;Reporting Services Account: Domain account, no admin privileges. Usually name it as a &lt;strong&gt;Domain\ReportingServices&lt;/strong&gt;. Set this with &lt;strong&gt;Reporting Service Configuration Manager&lt;/strong&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;Application Pool Account: Domain account, no admin privileges. Usually name as &lt;strong&gt;Domain\SP_SSRSApp&lt;/strong&gt;. Use this when the Web Application is created with SharePoint.&lt;/p&gt;  &lt;p align="justify"&gt;Site Collection (or Site) account: Domain account, need local admin rights. Usually name as &lt;strong&gt;Domain\SP_Admin&lt;/strong&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;** All accounts are maintained as &lt;strong&gt;Managed Accounts&lt;/strong&gt; in SharePoint.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Reporting Services Windows Service Account&lt;/font&gt;&lt;/strong&gt;    &lt;br /&gt;This should be a domain account. Once it is set with &lt;strong&gt;Reporting Services Configuration Manager&lt;/strong&gt;, you need add the same account to SharePoint too. First, have it as a &lt;strong&gt;Managed Account&lt;/strong&gt; (Central Administration –&amp;gt; Security –&amp;gt; General Security –&amp;gt; Configure Managed Accounts). Then add the account to the Site where you have configured &lt;strong&gt;Reporting Services Libraries&lt;/strong&gt;. You can add this account to &lt;strong&gt;Home Members&lt;/strong&gt; group. Errors you may get if it is not added are “&lt;font color="#ff0000"&gt;The permissions granted to user ‘Domain\User’&lt;/font&gt; (what ever account you used for logged in)&lt;font color="#ff0000"&gt; are insufficient for performing this operation.&lt;/font&gt;” and “&lt;font color="#ff0000"&gt;rsAccessDenied&lt;/font&gt;”. Note that error has no link with the service account but it is related to it. You may get this error with Report Builder or BIDS when deploying reports, or viewing reports.&lt;/p&gt;  &lt;p align="justify"&gt;In addition to that, you need to make sure that the account is added to Web Application content database which is created for Web Application. If not, you may get and error “&lt;font color="#ff0000"&gt;Report Server has encountered a SharePoint error&lt;/font&gt;&lt;font color="#000000"&gt;”&lt;/font&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;Other than that, this account is in &lt;strong&gt;ReportServer&lt;/strong&gt; database too. It is automatically added, but make sure that it is there.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Allow Anonymous Setting&lt;/font&gt;&lt;/strong&gt;    &lt;br /&gt;Make sure that &lt;strong&gt;Allow Anonymous&lt;/strong&gt; is set as &lt;strong&gt;false&lt;/strong&gt; when the Web Application is created. I faced an issue related deployment from BIDS if this is not set to false (read my &lt;a href="http://dinesql.blogspot.com/2011/01/sharepoint-integrated-reporting.html" target="_blank"&gt;post&lt;/a&gt; on it). Once the application is created, double-check with IIS (Site –&amp;gt; Authentication) and see whether it is disabled. As per the &lt;strong&gt;Authentication&lt;/strong&gt; and &lt;strong&gt;Authentication Provider&lt;/strong&gt; we set, Only &lt;strong&gt;ASP.NET Authentication &lt;/strong&gt;and &lt;strong&gt;Windows Authentication&lt;/strong&gt; should be enabled.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-5690516761234051265?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/5690516761234051265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=5690516761234051265&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5690516761234051265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5690516761234051265'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/01/configuring-reporting-services-2008-r2.html' title='Configuring Reporting Services 2008 R2 in SharePoint 2010 Integrated Mode – Part III'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-1099707162637794535</id><published>2011-01-19T08:31:00.001-08:00</published><updated>2011-01-19T16:24:59.299-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Reporting Services 2008 R2'/><title type='text'>SharePoint Integrated Reporting Services: BIDS pops up Login Dialog box indefinitely</title><content type='html'>&lt;p align="justify"&gt;Annoying…. This is all about SharePoint integrated Reporting Services deployment via BIDS. Web application for Reporting Services has been created with SharePoint 2010 and all necessary libraries are added (if you need to see the way of configuring SSRS 2008 R2 in SharePoint 2010, please see my posts &lt;a href="http://dinesql.blogspot.com/2010/06/configuring-reporting-services-2008-r2.html"&gt;Configuring Reporting Services 2008 R2 in SharePoint 2010 Integrated Mode – Part I&lt;/a&gt; and &lt;a href="http://dinesql.blogspot.com/2010/06/configuring-reporting-services-2008-r2_07.html"&gt;Configuring Reporting Services 2008 R2 in SharePoint 2010 Integrated Mode – Part II&lt;/a&gt;).&lt;/p&gt;  &lt;p align="justify"&gt;Now the problem is, popping up login dialog box indefinitely in BIDS when try to deploy reports, regardless of what account is supplied. As usual, went through the internet, found many solution but none of them worked for me. One of picked solutions by me is, disabling anonymous user. But it did not work too.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#c0504d"&gt;Solution&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;After all unsuccessful attempts, I created a new web application and set the &lt;strong&gt;Anonymous Access&lt;/strong&gt; to &lt;strong&gt;No &lt;/strong&gt;when creating the Web Application. Then I pointed the project’s target URL to newly created site, Wow, no login dialog box. I tried the same with old site too (by disabling &lt;strong&gt;Anonymous Authentication&lt;/strong&gt; in IIS) but did not work. So, not sure about this solution but it worked with the new site. If you face the same, try a new site and see.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-1099707162637794535?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/1099707162637794535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=1099707162637794535&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/1099707162637794535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/1099707162637794535'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/01/sharepoint-integrated-reporting.html' title='SharePoint Integrated Reporting Services: BIDS pops up Login Dialog box indefinitely'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-7416473788054590451</id><published>2011-01-16T07:50:00.001-08:00</published><updated>2011-01-16T07:50:00.194-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PerformancePoint'/><title type='text'>PerformancePoint 2010 Error: The URL is not available, does not reference a SharePoint site, or you do not have permission to connect.</title><content type='html'>&lt;p align="justify"&gt;If you face for this error when connecting to SharePoint site through PerformancePoint designer;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TTMTniqXfDI/AAAAAAAAAwc/8HICeBibLhM/s1600-h/Image2%5B7%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image2" border="0" alt="Image2" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TTMTo3d-S3I/AAAAAAAAAwg/5cvfSUkuwks/Image2_thumb%5B3%5D.png?imgmax=800" width="420" height="274" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;/p&gt;  &lt;p align="justify"&gt;… then check the domain account which has been used for PerformancePoint service application has been added to site content database as an owner. Once added, you are not going to see this error &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TTMTppj_FsI/AAAAAAAAAwk/7yH3bWLZyPk/wlEmoticon-smile%5B2%5D.png?imgmax=800" /&gt;.    &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-7416473788054590451?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/7416473788054590451/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=7416473788054590451&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7416473788054590451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7416473788054590451'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/01/performancepoint-2010-error-url-is-not.html' title='PerformancePoint 2010 Error: The URL is not available, does not reference a SharePoint site, or you do not have permission to connect.'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_p0AH7nWLB-k/TTMTo3d-S3I/AAAAAAAAAwg/5cvfSUkuwks/s72-c/Image2_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-1120495434401473780</id><published>2011-01-16T07:42:00.001-08:00</published><updated>2011-01-16T07:42:37.260-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PerformancePoint'/><title type='text'>PerformancePoint 2010 Error: The URL must be in one of the following zones: Local, Intranet, or Trusted</title><content type='html'>&lt;p&gt;If you face for this error when connecting to SharePoint server from Dashboard Designer;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TTMR2oUqwrI/AAAAAAAAAwM/5Zwvr8gE4lI/s1600-h/Image1%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image1" border="0" alt="Image1" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TTMR37lRArI/AAAAAAAAAwQ/jTbNtLqJpTk/Image1_thumb%5B1%5D.png?imgmax=800" width="409" height="205" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;… simply add the site for &lt;strong&gt;Trusted Sites&lt;/strong&gt; in your Internet Explorer.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TTMR4_2Ea8I/AAAAAAAAAwU/cpMVaL_NLwc/s1600-h/Image3%5B5%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image3" border="0" alt="Image3" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TTMR61ahPWI/AAAAAAAAAwY/y7IjlI5wQ7Q/Image3_thumb%5B3%5D.png?imgmax=800" width="408" height="421" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-1120495434401473780?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/1120495434401473780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=1120495434401473780&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/1120495434401473780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/1120495434401473780'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/01/performancepoint-2010-error-url-must-be.html' title='PerformancePoint 2010 Error: The URL must be in one of the following zones: Local, Intranet, or Trusted'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_p0AH7nWLB-k/TTMR37lRArI/AAAAAAAAAwQ/jTbNtLqJpTk/s72-c/Image1_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-7538555714021775151</id><published>2011-01-14T18:41:00.001-08:00</published><updated>2011-01-14T18:41:11.891-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='6231A'/><title type='text'>MCTS: SQL Server Database Administrator – Maintaining a MS SQL Server Database 2008 – 6231A Course</title><content type='html'>&lt;p align="justify"&gt;&lt;font color="#c0504d" size="3"&gt;&lt;strong&gt;Course 6231A: Maintaining a SQL Server 2008 Database – &lt;/strong&gt;&lt;/font&gt;This is my first class for 2011. Class will be started on Sunday, 23rd January 2011. If you are a DBA or interest on SQL Server Administration, join with us. Some topics that are covered with this course are Installing and Configuring, Security, Back up strategies, Disaster Recovery, High Availability, Replication and data transferring (see more on &lt;a href="http://www.microsoft.com/learning/en/us/course.aspx?id=6231A"&gt;http://www.microsoft.com/learning/en/us/course.aspx?id=6231A&lt;/a&gt;).&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font color="#c0504d" size="3"&gt;&lt;strong&gt;Good news! Microsoft gives 40% discount&lt;/strong&gt;&lt;/font&gt; for students for Microsoft exams. All you have to do is, go to an authorized Centre and prove that you are a student of any university (both private and government), then you get 40% discount for any exam. Good Luck!&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TTEJEy17pVI/AAAAAAAAAwE/mHZP-0CfPfU/s1600-h/SQL%20Class%5B3%5D.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="SQL Class" border="0" alt="SQL Class" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TTEJRMY5UUI/AAAAAAAAAwI/BFc3LH3LFQ4/SQL%20Class_thumb%5B1%5D.jpg?imgmax=800" width="396" height="403" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-7538555714021775151?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/7538555714021775151/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=7538555714021775151&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7538555714021775151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7538555714021775151'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/01/mcts-sql-server-database-administrator.html' title='MCTS: SQL Server Database Administrator – Maintaining a MS SQL Server Database 2008 – 6231A Course'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_p0AH7nWLB-k/TTEJRMY5UUI/AAAAAAAAAwI/BFc3LH3LFQ4/s72-c/SQL%20Class_thumb%5B1%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-153475459950867028</id><published>2011-01-10T03:01:00.001-08:00</published><updated>2011-01-10T03:01:25.924-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Host Header'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>Cannot login to SharePoint 2010 site when the Host Header is set</title><content type='html'>&lt;p align="justify"&gt;Everybody prefers a good URL for sites rather than server name with ports. Same for SharePoint Web Applications (SharePoint sites). When a Web Application is created, it allows us to set the URL for the site as we want through &lt;strong&gt;Host Header&lt;/strong&gt; as well as the port. For example, when a Web Application is created as &lt;a href="http://SPServerName:3000"&gt;http://SPServerName:3000&lt;/a&gt; , URL can be set as &lt;a href="http://MyTestWeb.com"&gt;http://MyTestWeb.com&lt;/a&gt; with &lt;strong&gt;Host Header&lt;/strong&gt; input box. Once created you need to make sure that a DNS record is created and pointed to SharePoint server. &lt;/p&gt;  &lt;p align="justify"&gt;My environment is set up with two Windows 2008 R2 Enterprise Editions. Once server is configured as the Domain Controller and other has SharePoint 2010 and SQL Server 2008 R2.&lt;/p&gt;  &lt;p align="justify"&gt;Here is the way I set;&lt;/p&gt;  &lt;p align="justify"&gt;Add URL I need for the Web Application:   &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TSrmw9bFpKI/AAAAAAAAAvs/6Yubh6wMpnI/s1600-h/WebApp%5B4%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="WebApp" border="0" alt="WebApp" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TSrm0yZkwOI/AAAAAAAAAvw/OkktQaTWpnw/WebApp_thumb%5B2%5D.png?imgmax=800" width="393" height="337" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Set DNS record in DNS Server, in my case it is DC:   &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TSrm3BwIu1I/AAAAAAAAAv0/erGXqLOk_BQ/s1600-h/DNS%5B7%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="DNS" border="0" alt="DNS" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TSrm6s8nSLI/AAAAAAAAAv4/d-cfkkzNnYw/DNS_thumb%5B3%5D.png?imgmax=800" width="399" height="328" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Done. I should be able to navigate my site (after creating a Site Collection for the Web Application) using the URL set with Host Header (in my case, it is &lt;a href="http://bi.andromeda.com"&gt;http://bi.andromeda.com&lt;/a&gt;) without using &lt;a href="http://W2008R2-SP:30000"&gt;http://W2008R2-SP:30000&lt;/a&gt; . But I am unable….&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font color="#d16349"&gt;&lt;strong&gt;My Problem&lt;/strong&gt; &lt;/font&gt;    &lt;br /&gt;When I open the browser for &lt;a href="http://bi.andromeda.com"&gt;http://bi.andromeda.com&lt;/a&gt; , browser prompts me the authentication dialog box and asks for an user id and a password. It prompts three times even with correct user id and password and then opens a blank page. Could not figure out the reason for a while, finally &lt;a href="http://prabathf.blogspot.com/" target="_blank"&gt;Prabath&lt;/a&gt; sent me an URL that contains a solution for this. The solution is given by &lt;strong&gt;Tech Battle Field&lt;/strong&gt; and post is &lt;a href="http://spiderwool.blogspot.com/2010/09/access-denied-host-header-sharepoint.html"&gt;http://spiderwool.blogspot.com/2010/09/access-denied-host-header-sharepoint.html&lt;/a&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;In summary, solution is adding a new &lt;strong&gt;Multi-String&lt;/strong&gt; registry key named &lt;strong&gt;BackConnectionHostNames&lt;/strong&gt; in SharePoint server at &lt;strong&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0&lt;/strong&gt; and set the host names with values (Read the post for more details). This is what I did:    &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TSrm9ZBc53I/AAAAAAAAAv8/2M2R3QIvOto/s1600-h/Registry%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Registry" border="0" alt="Registry" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TSrnAySxqJI/AAAAAAAAAwA/t0IRTM_tUg8/Registry_thumb%5B1%5D.png?imgmax=800" width="398" height="206" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Finally it worked. Thanks for &lt;strong&gt;&lt;a href="http://spiderwool.blogspot.com" target="_blank"&gt;Tech Battle Field&lt;/a&gt;&lt;/strong&gt; for sharing this and thanks for &lt;a href="http://prabathf.blogspot.com/" target="_blank"&gt;Prabath&lt;/a&gt; for guiding me onto it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-153475459950867028?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/153475459950867028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=153475459950867028&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/153475459950867028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/153475459950867028'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/01/cannot-login-to-sharepoint-2010-site.html' title='Cannot login to SharePoint 2010 site when the Host Header is set'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_p0AH7nWLB-k/TSrm0yZkwOI/AAAAAAAAAvw/OkktQaTWpnw/s72-c/WebApp_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-5082740142975979120</id><published>2011-01-04T03:30:00.001-08:00</published><updated>2011-01-04T03:30:01.984-08:00</updated><title type='text'>Awarded Microsoft MVP again for 6th time</title><content type='html'>&lt;p&gt;&lt;img style="margin: 0px 0px 5px; display: inline; float: left" align="left" src="http://lh6.ggpht.com/_p0AH7nWLB-k/S0KW_H0DJiI/AAAAAAAAAdc/6V_pT3tMmQY/MVPLogo_thumb%5B1%5D.gif?imgmax=800" /&gt;&lt;/p&gt;  &lt;p&gt; MVP again!&lt;/p&gt;  &lt;p&gt; Microsoft has awarded the title again for the 6th time, thanks for Microsoft, Microsoft Sri Lanka, &lt;a href="http://welasharp.net/"&gt;Wellignton&lt;/a&gt; and &lt;a href="http://lilianq-thatwasthenthisisnow.blogspot.com/"&gt;Lilian&lt;/a&gt; for recommending me.&lt;/p&gt;  &lt;p&gt; Two new MVPs are introduced; &lt;a href="http://prabathf.blogspot.com/" target="_blank"&gt;Prabath Fonseka&lt;/a&gt; (SharePoint) and &lt;a href="http://preethiviraj.blogspot.com/" target="_blank"&gt;Preethiviraj&lt;/a&gt; (SQL), Congratulation guys!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-5082740142975979120?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/5082740142975979120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=5082740142975979120&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5082740142975979120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5082740142975979120'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2011/01/awarded-microsoft-mvp-again-for-6th.html' title='Awarded Microsoft MVP again for 6th time'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_p0AH7nWLB-k/S0KW_H0DJiI/AAAAAAAAAdc/6V_pT3tMmQY/s72-c/MVPLogo_thumb%5B1%5D.gif?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-9211068108392435802</id><published>2010-11-24T18:08:00.001-08:00</published><updated>2010-11-24T18:08:05.726-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Analysis Services'/><title type='text'>Analysis Services Security: Dimension Data – Select all members or Deselect all members?</title><content type='html'>&lt;p align="justify"&gt;While configuring Analysis Services security on Dimension Data, I did not pay much attention on two options available with the screen; &lt;strong&gt;Select all members&lt;/strong&gt; and &lt;strong&gt;Deselect all members&lt;/strong&gt;. However the importance of them was raised up when my colleague &lt;a href="http://www.myspace.com/462179362/blog" target="_blank"&gt;Asanka Padmakumara&lt;/a&gt; showed a point on them. Which one should we select? See the screen below;    &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TO3Epnl4LJI/AAAAAAAAAvI/ENTuNwKvaxQ/s1600-h/SelectAll%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="SelectAll" border="0" alt="SelectAll" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TO3EsmPo9MI/AAAAAAAAAvM/2zrRV1crr9c/SelectAll_thumb%5B1%5D.png?imgmax=800" width="394" height="304" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;I have selected the first option which is &lt;strong&gt;Select all members &lt;/strong&gt;and granted permission on &lt;strong&gt;Accessories &lt;/strong&gt;and &lt;strong&gt;Bikes&lt;/strong&gt;. I can do the same, select the other option too. Let’s move into &lt;strong&gt;Advanced&lt;/strong&gt; section and see how it has been set;    &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TO3Ev3Pcz5I/AAAAAAAAAvQ/Fx1bYccB71c/s1600-h/SelectAllAdvanced%5B7%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="SelectAllAdvanced" border="0" alt="SelectAllAdvanced" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TO3Eyd5SoDI/AAAAAAAAAvU/5zacNNkgaXk/SelectAllAdvanced_thumb%5B3%5D.png?imgmax=800" width="392" height="303" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Note that &lt;u&gt;other two categories&lt;/u&gt; (&lt;strong&gt;Clothing&lt;/strong&gt; and &lt;strong&gt;Components&lt;/strong&gt;) have been added under &lt;strong&gt;Denied member set&lt;/strong&gt;. What we have set? Yes, we granted permission on &lt;strong&gt;Accessories &lt;/strong&gt;and &lt;strong&gt;Bikes&lt;/strong&gt; but we have done indirectly is, denying permission on &lt;strong&gt;Clothing &lt;/strong&gt;and &lt;strong&gt;Components&lt;/strong&gt;. Main thing we need to consider is, permission on future categories. Since the items we did not select have gone to &lt;strong&gt;Denied member list&lt;/strong&gt;, all future items will be available for this role. If you need to let this role to access future categories without explicitly setting them, use &lt;strong&gt;Select all members&lt;/strong&gt; for setting permission.&lt;/p&gt;  &lt;p align="justify"&gt;Now let’s use the other option; &lt;strong&gt;Deselect all members&lt;/strong&gt;;    &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TO3E2jZc_vI/AAAAAAAAAvY/dW5h6dUc2lo/s1600-h/Deselect%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Deselect" border="0" alt="Deselect" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TO3E53TNCxI/AAAAAAAAAvc/jTLgdOaz4aM/Deselect_thumb%5B1%5D.png?imgmax=800" width="393" height="304" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;I have given same permission set but the option selected is &lt;strong&gt;Deselect all members&lt;/strong&gt;. Have a look on &lt;strong&gt;Advanced &lt;/strong&gt;section now;    &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_p0AH7nWLB-k/TO3E9s8m3aI/AAAAAAAAAvg/pbyJRlBJZ8o/s1600-h/DeselectAdv%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="DeselectAdv" border="0" alt="DeselectAdv" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TO3FAug5lQI/AAAAAAAAAvk/fTMzLZ6zwn0/DeselectAdv_thumb%5B1%5D.png?imgmax=800" width="392" height="303" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Now you can see the &lt;u&gt;items we selected&lt;/u&gt; have been added to &lt;strong&gt;Allowed member set&lt;/strong&gt;. This means all other items we did not select are denied to this role. What will happen to future categories? This is the difference. Since we have explicitly added &lt;strong&gt;Accessories&lt;/strong&gt; and &lt;strong&gt;Bikes&lt;/strong&gt; to &lt;strong&gt;Allowed member set&lt;/strong&gt;, future items will &lt;u&gt;NOT&lt;/u&gt; be available under &lt;strong&gt;Allowed member set&lt;/strong&gt;. If you need to disallow this role to access future categories without explicitly setting them, use &lt;strong&gt;Deselect all members&lt;/strong&gt; for setting permission.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-9211068108392435802?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/9211068108392435802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=9211068108392435802&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/9211068108392435802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/9211068108392435802'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/11/analysis-services-security-dimension.html' title='Analysis Services Security: Dimension Data – Select all members or Deselect all members?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_p0AH7nWLB-k/TO3EsmPo9MI/AAAAAAAAAvM/2zrRV1crr9c/s72-c/SelectAll_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-6789568883199053813</id><published>2010-11-22T07:06:00.001-08:00</published><updated>2010-11-22T07:06:48.495-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Analysis Services'/><title type='text'>Analysis Services Security: DENY does not override GRANT</title><content type='html'>&lt;p align="justify"&gt;Is the famous rule of thumb broken? I am sure that you all are aware the rule and you know that DENY always wins over GRANT. If you want to see an exception (or a situation) read one of my previous posts “&lt;a href="http://dinesql.blogspot.com/2010/05/column-grant-overrides-deny-table.html" target="_blank"&gt;Column GRANT overrides DENY TABLE, Avoiding with Common Criteria Compliance&lt;/a&gt;”. &lt;/p&gt;  &lt;p align="justify"&gt;This post discusses another situation, it is not with SQL Server Relational Engine, it is will SQL Server Analysis Services.&lt;/p&gt;  &lt;p align="justify"&gt;Analysis Services behaves bit differently. As you know, if an object of SQL Server database is denied explicitly, it is always denied even with an explicit grant. For example, if you are in a &lt;strong&gt;Role&lt;/strong&gt; that grants &lt;strong&gt;SELECT&lt;/strong&gt; on &lt;strong&gt;Table1&lt;/strong&gt; and in another role that denies &lt;strong&gt;SELECT &lt;/strong&gt;on &lt;strong&gt;Table1&lt;/strong&gt;, you will not be able to execute &lt;strong&gt;SELECT&lt;/strong&gt; on &lt;strong&gt;Table1&lt;/strong&gt;. Analysis Services authorizes on items differently. It unions all grants and authorizes. If you are in a &lt;strong&gt;Role&lt;/strong&gt; that grants on &lt;strong&gt;Item1&lt;/strong&gt; and &lt;strong&gt;Item2&lt;/strong&gt; (&lt;em&gt;Note that in Analysis Services, once items are granted, all other items are denied, no need to explicitly deny them as SQL Server database engine objects&lt;/em&gt;) and in another &lt;strong&gt;Role&lt;/strong&gt; that grants &lt;strong&gt;Item2&lt;/strong&gt; and &lt;strong&gt;Item3&lt;/strong&gt;, you are granted for &lt;strong&gt;Item1&lt;/strong&gt;, &lt;strong&gt;Item2&lt;/strong&gt;, and &lt;strong&gt;Item3&lt;/strong&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;Let me show you a sample on this. The below image shows a &lt;strong&gt;Role&lt;/strong&gt; in Analysis Services &lt;strong&gt;Adventure Works DW 2008R2&lt;/strong&gt; database. This is how it is created;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Name: Business Users&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Membership: Dinesh&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Cubes: Adventure Works – Read&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Dimension Data: &lt;/div&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;div align="justify"&gt;Product Dimension, Category – granted for &lt;strong&gt;&lt;u&gt;Accessories&lt;/u&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;u&gt;Bikes&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;Other Dimensions – granted for all&lt;/div&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TOqGYFdFAwI/AAAAAAAAAuo/DlAt3X9WLuE/s1600-h/BusinessUsers4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="BusinessUsers" border="0" alt="BusinessUsers" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TOqGyEceQzI/AAAAAAAAAus/D5soxJuRiU4/BusinessUsers_thumb2.png?imgmax=800" width="408" height="318" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Second image shows another role in same database. Its properties are as follows;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Name: Coordinators&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Membership: Dinesh&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Cubes: Adventure Works – Read&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Dimension Data: &lt;/div&gt;   &lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;       &lt;div align="justify"&gt;Product Dimension, Category – granted for &lt;strong&gt;&lt;u&gt;Bikes&lt;/u&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;u&gt;Clothing&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;     &lt;/li&gt;      &lt;li&gt;       &lt;div align="justify"&gt;Other Dimensions – granted for all&lt;/div&gt;     &lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TOqGzoasFWI/AAAAAAAAAuw/P9oAW6IaGJQ/s1600-h/coordinators9.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="coordinators" border="0" alt="coordinators" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TOqG03oLCEI/AAAAAAAAAu0/BfCnN4T3o58/coordinators_thumb7.png?imgmax=800" width="413" height="329" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Business Users&lt;/strong&gt; role denies for &lt;strong&gt;Clothing&lt;/strong&gt; and &lt;strong&gt;Components&lt;/strong&gt;. &lt;strong&gt;Coordinators&lt;/strong&gt; role denies for &lt;strong&gt;Accessories&lt;/strong&gt; and &lt;strong&gt;Components&lt;/strong&gt;. When &lt;strong&gt;Dinesh&lt;/strong&gt; sees data, he sees union of both; &lt;strong&gt;Accessories&lt;/strong&gt;, &lt;strong&gt;Clothing&lt;/strong&gt;, and &lt;strong&gt;Bikes&lt;/strong&gt;. The reason for this is, Analysis Services uses all GRANTs from all Roles for connected user and then authorizes. That is why he sees&lt;strong&gt; Accessories&lt;/strong&gt; and &lt;strong&gt;Clothing &lt;/strong&gt;even though they are denied from each role. This is how he sees when Categories are loaded with Excel.     &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TOqG8p8vn6I/AAAAAAAAAu4/6K2faRqc98c/s1600-h/eXCEL3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="eXCEL" border="0" alt="eXCEL" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TOqG-FBGlQI/AAAAAAAAAu8/Eby-MEOn_ts/eXCEL_thumb1.png?imgmax=800" width="403" height="382" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Note: This type of security cab be tested with &lt;strong&gt;Management Studio &lt;/strong&gt;too. Start &lt;strong&gt;Cube Browser&lt;/strong&gt; and click on &lt;strong&gt;Change User&lt;/strong&gt; icon. The opened window allows you to set the context with &lt;strong&gt;Current User&lt;/strong&gt;, &lt;strong&gt;Other User&lt;/strong&gt;, or &lt;strong&gt;Roles&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TOqG_3SNe0I/AAAAAAAAAvA/4-35Z8xwL5A/s1600-h/roles%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="roles" border="0" alt="roles" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TOqHBocv21I/AAAAAAAAAvE/XSStCwYH_c8/roles_thumb%5B1%5D.png?imgmax=800" width="401" height="273" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-6789568883199053813?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/6789568883199053813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=6789568883199053813&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/6789568883199053813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/6789568883199053813'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/11/analysis-services-security-deny-does.html' title='Analysis Services Security: DENY does not override GRANT'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_p0AH7nWLB-k/TOqGyEceQzI/AAAAAAAAAus/D5soxJuRiU4/s72-c/BusinessUsers_thumb2.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-800012450872735799</id><published>2010-11-16T18:02:00.001-08:00</published><updated>2010-11-16T18:02:56.569-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Project Crescent'/><title type='text'>Way to Visualize: Project Crescent; What is it?</title><content type='html'>&lt;p align="justify"&gt;The Era that Business User is used to carry an armload of tools for analyzing and visualizing data, has come to an end!!!!! Yes, Microsoft never stops making business user’s life easier. Microsoft never stop supporting business user to manage and visualize data in a rich way. Microsoft has come out with an exciting facility; The Project Crescent.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#800000"&gt;What is Project Crescent?&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_p0AH7nWLB-k/TOM3e-cXgRI/AAAAAAAAAuU/UQTHxnCrNOw/s1600-h/8507.clip_image00264_34B94EA4%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="8507.clip_image00264_34B94EA4" border="0" alt="8507.clip_image00264_34B94EA4" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TOM3p2gxDUI/AAAAAAAAAuY/Zt-I-Gzz40g/8507.clip_image00264_34B94EA4_thumb.jpg?imgmax=800" width="191" height="118" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Project Crescent is the recent Microsoft Business Intelligence team innovation that helps to manage and visualize large amount of data quickly in very rich format. It has been built entirely on Silverlight and will be available as a BI client. It allows to show the insights of the business with reports, with highly interactive visualization and animations.    &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TOM3xTP6mlI/AAAAAAAAAuc/ZrkByYTbZWQ/s1600-h/crescent%5B3%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="crescent" border="0" alt="crescent" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TOM3yyjps2I/AAAAAAAAAug/XOiB_4KGjjU/crescent_thumb%5B1%5D.png?imgmax=800" width="376" height="199" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;The releasing date of this is unknown. Most probably it will be released with &lt;strong&gt;Denali&lt;/strong&gt;, at the end of 2011 or beginning of 2012. Long time to wait…..&lt;/p&gt;  &lt;p align="justify"&gt;Here is a sneak peak of project Crescent, in Amir Netz’ demo at PASS Summit 2010: &lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:3e349a88-8256-4795-ae41-a8da65f779cb" class="wlWriterEditableSmartContent"&gt;&lt;div id="23969c0b-6a5d-458f-99f2-ebb8932386d7" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://www.youtube.com/watch?v=FfRpfCav9hg&amp;amp;feature=player_embedded" target="_new"&gt;&lt;img src="http://lh5.ggpht.com/_p0AH7nWLB-k/TOM3zghzwSI/AAAAAAAAAuk/nF9pl1X_4L0/video5d908a4deada%5B2%5D.jpg?imgmax=800" style="border-style: none" galleryimg="no" onload="var downlevelDiv = document.getElementById('23969c0b-6a5d-458f-99f2-ebb8932386d7'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;object width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;param name=\&amp;quot;movie\&amp;quot; value=\&amp;quot;http://www.youtube.com/v/FfRpfCav9hg&amp;amp;hl=en\&amp;quot;&amp;gt;&amp;lt;\/param&amp;gt;&amp;lt;embed src=\&amp;quot;http://www.youtube.com/v/FfRpfCav9hg&amp;amp;hl=en\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/object&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;  &lt;p&gt;Here is a post from SQL Server Reporting Services team blog: &lt;a title="http://www.silverlightshow.net/news/Project-Crescent-built-entirely-on-Silverlight.aspx" href="http://www.silverlightshow.net/news/Project-Crescent-built-entirely-on-Silverlight.aspx"&gt;http://www.silverlightshow.net/news/Project-Crescent-built-entirely-on-Silverlight.aspx&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-800012450872735799?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/800012450872735799/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=800012450872735799&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/800012450872735799'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/800012450872735799'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/11/way-to-visualize-project-crescent-what.html' title='Way to Visualize: Project Crescent; What is it?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_p0AH7nWLB-k/TOM3p2gxDUI/AAAAAAAAAuY/Zt-I-Gzz40g/s72-c/8507.clip_image00264_34B94EA4_thumb.jpg?imgmax=800' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-6171844497668589370</id><published>2010-11-12T01:31:00.001-08:00</published><updated>2010-11-12T01:31:49.413-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='RDLC'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Reporting Services 2008'/><title type='text'>Reporting Services: Difference between RDL and RDLC files</title><content type='html'>&lt;p align="justify"&gt;Microsoft Reporting Services is an enterprise-capable reporting solution that can be used to create all types of reports such as Production, Analytical, and Dashboard. Building reports is done through Business Intelligence Development Studio which is an extension of Visual Studio. Reports are created as RDL (Report Definition Language) files. Once the reports are created with BIDS, they (RDLs) are hosted in Reporting Services and users can be accessed them in many ways.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font color="#800000"&gt;&lt;strong&gt;What are RDLC files?&lt;/strong&gt;&lt;/font&gt;     &lt;br /&gt;RDLC: &lt;strong&gt;R&lt;/strong&gt;eport &lt;strong&gt;D&lt;/strong&gt;efinition &lt;strong&gt;L&lt;/strong&gt;anguage, &lt;strong&gt;C&lt;/strong&gt;lient Side files are files that are generated with either &lt;strong&gt;ReportViewer Control&lt;/strong&gt; that comes with Visual Studio 2008 W&lt;strong&gt;indows or ASP.NET&lt;/strong&gt; project templates, or &lt;strong&gt;Reporing –&amp;gt; Report Application&lt;/strong&gt; project template. It is a XML file, just like the RDL. It uses the same XML schema that is used by RDL files but RDLC does not require to have values for all elements such as query text. If RDLC file is needed to be hosted in Reporting Services, it needs to be renamed as RDL and all empty elements must be filled manually. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Reporting with ReportViewer Control        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;The &lt;strong&gt;ReportViewer Control&lt;/strong&gt; allows us to embed a report to ASP.NET web page or Windows form. It supports two modes: Remote Processing mode and Local Processing mode. The Remote Processing mode allows to connect with reports that have been already deployed to SSRS instance. In this case, all the processing take place at the SSRS server. The Local Processing mode allows to create reports within Visual Studio itself. The extension of them are RDLC. This does not require an instance of Reporting Services, hence processing is handled by the client application.&lt;/p&gt;  &lt;p align="justify"&gt;Here are some of important points to remember about these two modes:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Local Processing mode does not require an instance of Reporting Services, hence a license for Reporting Services is not required.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Local Processing mode is not recommended for large reports. It is used for small, OLTP types of reports. They may run infrequently.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Remote Processing can be scaled out but Local Processing.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Local Processing mode supports following extensions only:&lt;/div&gt;   &lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;       &lt;div align="justify"&gt;Visual Studio 2008: PDF and Excel&lt;/div&gt;     &lt;/li&gt;      &lt;li&gt;       &lt;div align="justify"&gt;Visual Studio 2010: PDF, Excel and Word&lt;/div&gt;     &lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Local Processing mode with Visual Studio 2008 does not support Tablix data region. Visual Studio 2010 supports.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Mapping parameters with query parameters has to be done manually with Local Processing mode.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-6171844497668589370?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/6171844497668589370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=6171844497668589370&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/6171844497668589370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/6171844497668589370'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/11/reporting-services-difference-between.html' title='Reporting Services: Difference between RDL and RDLC files'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-6471189675045860351</id><published>2010-11-11T20:37:00.001-08:00</published><updated>2010-11-11T20:37:40.271-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Denali'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Future version of SQL Server: “Denali”, CTP available for downloading</title><content type='html'>&lt;p align="justify"&gt;Microsoft announced that Community Technology Preview of SQL Server code-named “Denali” available for downloading. This CTP contains enhancements mainly on SQL Server high availability and engine not with BI components such as Analysis Services and Reporting Services.&lt;/p&gt;  &lt;p&gt;To see details: &lt;a href="http://www.microsoft.com/sqlserver/en/us/product-info/future-editions.aspx"&gt;http://www.microsoft.com/sqlserver/en/us/product-info/future-editions.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To download: &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6a04f16f-f6be-4f92-9c92-f7e5677d91f9&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6a04f16f-f6be-4f92-9c92-f7e5677d91f9&amp;amp;displaylang=en&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To see the enhancements: &lt;a href="http://msdn.microsoft.com/en-us/library/bb500435(SQL.110).aspx"&gt;http://msdn.microsoft.com/en-us/library/bb500435(SQL.110).aspx&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-6471189675045860351?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/6471189675045860351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=6471189675045860351&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/6471189675045860351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/6471189675045860351'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/11/future-version-of-sql-server-denali-ctp.html' title='Future version of SQL Server: “Denali”, CTP available for downloading'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-910028011304489104</id><published>2010-11-04T04:34:00.001-07:00</published><updated>2010-11-04T04:34:50.351-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>Ready-made Virtual Machine for SharePoint 2010</title><content type='html'>&lt;p&gt;Are you looking for pre-built virtual machine that includes SharePoint 2010? If yes, here it is… it is available for downloading.&lt;/p&gt;  &lt;p&gt;Not only SharePoint 2010, it contains:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Microsoft Office Communication Server 2007 R2&lt;/li&gt;    &lt;li&gt;Microsoft Visual Studio 2010&lt;/li&gt;    &lt;li&gt;Microsoft SharePoint Server 2010 Enterprise Edition&lt;/li&gt;    &lt;li&gt;Microsoft Office Web Applications&lt;/li&gt;    &lt;li&gt;Microsoft FAST Search for SharePoint 2010&lt;/li&gt;    &lt;li&gt;Microsoft Project Server 2010&lt;/li&gt;    &lt;li&gt;Microsoft Office Professional Plus 2010&lt;/li&gt;    &lt;li&gt;Microsoft Visio 2010&lt;/li&gt;    &lt;li&gt;Microsoft Project 2010&lt;/li&gt;    &lt;li&gt;Microsoft Office Communicator 2007 R2&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;For more details and downloading: &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=751fa0d1-356c-4002-9c60-d539896c66ce&amp;amp;displaylang=en" target="_blank"&gt;2010 Information Worker Demonstration and Evaluation Virtual Machine&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-910028011304489104?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/910028011304489104/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=910028011304489104&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/910028011304489104'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/910028011304489104'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/11/ready-made-virtual-machine-for.html' title='Ready-made Virtual Machine for SharePoint 2010'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-7399302490324976624</id><published>2010-11-02T18:02:00.001-07:00</published><updated>2010-11-02T18:02:49.102-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint Videos: SharePoint 2010 Developer Training Course</title><content type='html'>&lt;p align="justify"&gt;Looking for resources to learn SharePoint 2010 development? So many books, articles, and blog posts? Here is an easy way to learn it;&lt;/p&gt;  &lt;p align="justify"&gt;Site: &lt;a href="http://channel9.msdn.com/learn/courses/SharePoint2010Developer" target="_blank"&gt;SharePoint 2010 Developer Training Course&lt;/a&gt;    &lt;br /&gt;Download link: &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=83a80a0f-0906-4d7d-98e1-3dd6f58ff059&amp;amp;displayLang=en" target="_blank"&gt;SharePoint 2010 Developer Training Kit&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;This training kit provides videos and hands on labs which are very useful to understand how SharePoint 2010 works and how it can be used.&lt;/p&gt;  &lt;p align="justify"&gt;We must thank &lt;a href="http://blogs.msdn.com/b/cmayo/" target="_blank"&gt;Chris Mayo&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/b/donovanf/" target="_blank"&gt;Donovan Follette&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/b/girishr/" target="_blank"&gt;Girish Raja&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/b/pstubbs/" target="_blank"&gt;Paul Stubbs&lt;/a&gt;, and &lt;a href="http://blogs.msdn.com/b/steve_fox/" target="_blank"&gt;Steve Fox&lt;/a&gt; for preparing something like this for developers.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-7399302490324976624?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/7399302490324976624/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=7399302490324976624&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7399302490324976624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7399302490324976624'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/11/sharepoint-videos-sharepoint-2010.html' title='SharePoint Videos: SharePoint 2010 Developer Training Course'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-3345211944719154246</id><published>2010-11-01T03:25:00.001-07:00</published><updated>2010-11-01T03:25:33.080-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Business Intelligence'/><category scheme='http://www.blogger.com/atom/ns#' term='SSIS'/><category scheme='http://www.blogger.com/atom/ns#' term='MERGE'/><category scheme='http://www.blogger.com/atom/ns#' term='Slowly Changing Dimensions'/><title type='text'>SSIS: Replacing Slowly Changing Dimension (SCD) wizard with the MERGE statement</title><content type='html'>&lt;p align="justify"&gt;Slowly Changing Dimensions are business entities in DW/BI systems that have attributes that do not change very often. In order to handle loading of SCDs, we use SQL Server Integration Services Data Flow component: Slowly Changing Dimension Component. It is a wizard that helps us to handle changing attributes.&lt;/p&gt;  &lt;p align="justify"&gt;If you are a SSIS developer and have used SCD wizard, you have already seen the bad performance on it. It works fine with a dataset that contains records less than something around 5000 (&lt;em&gt;this is what I have seen, please do not consider it is as a benchmark&lt;/em&gt;) but gives very slow performance on beyond. Recently, I noticed that one of the projects done had used SCD wizard for almost all data loading and the time it takes for completing the load has gone from 5 minutes for 5-6 hours. It significantly increases the time when the data load is getting higher and higher. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;How to improve the performance of loading of SCDs?&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;I had to give a solution for this…. two things came into my mind, one is &lt;a href="http://kimballscd.codeplex.com/" target="_blank"&gt;Kimball Method SSIS Slowly Changing Dimension Component&lt;/a&gt; (&lt;em&gt;will make a separate post on this&lt;/em&gt;) and the other is MERGE T-SQL statement. Although the MERGE implementation is bit complex, I thought to recommend the MERGE because many have accepted that the performance it gives is superb. The below table shows a comparison made on three different approaches on SCDs loading with some criteria (which is quoted from &lt;a href="http://blogs.msdn.com/b/mattm" target="_blank"&gt;Matt Masson&lt;/a&gt;’s presentation named Performance Design Pattern).&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TM6Vf1MhIgI/AAAAAAAAAtc/2J-dpszT8ek/s1600-h/table4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="table" border="0" alt="table" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TM6VhBJ1iyI/AAAAAAAAAtg/WT5b_AqHI84/table_thumb2.png?imgmax=800" width="406" height="204" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;You can easily notice that MERGE gives the best performance though there are drawbacks. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Type of Slowly Changing Dimensions&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;Slowly Changing Dimensions are categorized into three types named: Type 1, Type 2, and Type3. The Type 1 SCD does not maintain the history of changing attributes, it overwrites values of the attributes. Type 2 maintains historical values for changing attributes. Type 3 that we do not use much (I have not used it at all) maintains separate columns for changed attributes. SSIS SCD wizard supports both Type 1 and Type 2.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Using MERGE instead of SCD wizard&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;Replacement of SCD wizard with MERGE is not a straightforward technique. If the SCD has both Type 1 and Type 2 types attributes, they need to be handled separately. Let’s create a simple table with following set of data, in order to see the way of handling them with MERGE.     &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TM6ViNFWYqI/AAAAAAAAAtk/rUpE8E3l2kM/s1600-h/table1%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="table1" border="0" alt="table1" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TM6VjxE9n_I/AAAAAAAAAto/etP4Iu5GkY8/table1_thumb%5B1%5D.png?imgmax=800" width="402" height="86" /&gt;&lt;/a&gt; Following attributes in this table are Type 1:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;FirstName&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;LastName&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;Following attributes are Type 2:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;MaritalStatus&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Country&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;Following script creates the Dimension table and inserts data;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; dbo.DimCustomer&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    CustomerKey &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; &lt;span style="color: #0000ff"&gt;IDENTITY&lt;/span&gt;(1,1) &lt;span style="color: #0000ff"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: #0000ff"&gt;KEY&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , SourceCode &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;(5) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , FirstName &lt;span style="color: #0000ff"&gt;varchar&lt;/span&gt;(50) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt; &lt;span style="color: #008000"&gt;-- Type 1&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , LastName &lt;span style="color: #0000ff"&gt;varchar&lt;/span&gt;(50) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt; &lt;span style="color: #008000"&gt;-- Type 1&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , MaritalStatus &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;(1) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt; &lt;span style="color: #008000"&gt;-- Type 2&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , Country  &lt;span style="color: #0000ff"&gt;varchar&lt;/span&gt;(50) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt; &lt;span style="color: #008000"&gt;-- Type 2&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , StartDate &lt;span style="color: #0000ff"&gt;date&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , EndDate &lt;span style="color: #0000ff"&gt;date&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , &lt;span style="color: #0000ff"&gt;CONSTRAINT&lt;/span&gt; IX_DimCustomer_SourceCode &lt;span style="color: #0000ff"&gt;UNIQUE&lt;/span&gt; (SourceCode)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;INSERT &lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; dbo.DimCustomer&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    (SourceCode, FirstName, LastName, MaritalStatus, Country&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , StartDate, EndDate)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;VALUES&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    (&lt;span style="color: #006080"&gt;'AAAA1'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Dinesh'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Priyankara'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'M'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Sri Lanka'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        , &lt;span style="color: #006080"&gt;'01/01/2009'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'12/31/9999'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , (&lt;span style="color: #006080"&gt;'AAAA2'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Yeshan'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Senthush'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'S'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Sri Lanka'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        , &lt;span style="color: #006080"&gt;'01/01/2009'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'12/31/9999'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , (&lt;span style="color: #006080"&gt;'AAAA3'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Jane'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Alvarez'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'S'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'France'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        , &lt;span style="color: #006080"&gt;'01/01/2009'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'12/31/9999'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , (&lt;span style="color: #006080"&gt;'AAAA4'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Shannon'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Carlson'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'M'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'India'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        , &lt;span style="color: #006080"&gt;'01/01/2009'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'12/31/9999'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;When data loading of SCDs are handled with SSIS,what we usually do is, once the data set is captured, we send it through SCD component. The SCD component inserts new data, updates Type 1 data, and finally inserts Type 2 data. If we are to use MERGE, we need to send the captured data to a temporary table and then use &lt;strong&gt;Execute SQL Task&lt;/strong&gt; for executing the MERGE statement. Assume that following table is the temporary table and it is loaded with captured data.&amp;#160; &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TM6VkjenKoI/AAAAAAAAAts/rJnk9xuo2Ck/s1600-h/table2%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="table2" border="0" alt="table2" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TM6VmZ1iWOI/AAAAAAAAAtw/fPfTbPyuEQc/table2_thumb%5B1%5D.png?imgmax=800" width="391" height="116" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p align="justify"&gt;This code creates the table and populates data;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; dbo.TempDimCustomer&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    SourceCode &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;(5) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , FirstName &lt;span style="color: #0000ff"&gt;varchar&lt;/span&gt;(50) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , LastName &lt;span style="color: #0000ff"&gt;varchar&lt;/span&gt;(50) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , MaritalStatus &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;(1) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , Country  &lt;span style="color: #0000ff"&gt;varchar&lt;/span&gt;(50) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;)    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;INSERT &lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; dbo.TempDimCustomer&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    (SourceCode, FirstName, LastName, MaritalStatus, Country)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;VALUES&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    (&lt;span style="color: #006080"&gt;'AAAA1'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Dinesh'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Priyankara'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'M'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Sri Lanka'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , (&lt;span style="color: #006080"&gt;'AAAA2'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Yeshan'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Santhush'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'S'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Sri Lanka'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , (&lt;span style="color: #006080"&gt;'AAAA3'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Jane'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Alvarez'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'M'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'France'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , (&lt;span style="color: #006080"&gt;'AAAA4'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Shannon'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Carlson'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'M'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'German'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , (&lt;span style="color: #006080"&gt;'AAAA5'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Jon'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Yang'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'M'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'Japan'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Handling Type 1 attributes&lt;/font&gt;&lt;/strong&gt; 

  &lt;br /&gt;The below codes shows the MERGE statement that updates Type 1 attributes. Note that it goes through all records and updates.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;MERGE &lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; dbo.DimCustomer c&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;USING&lt;/span&gt; dbo.TempDimCustomer tc&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; (c.SourceCode = tc.SourceCode)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;WHEN&lt;/span&gt; MATCHED &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;AND&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        (c.FirstName != tc.FirstName&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;OR&lt;/span&gt; c.LastName != tc.LastName)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;THEN&lt;/span&gt; &lt;span style="color: #0000ff"&gt;UPDATE&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; c.FirstName = tc.FirstName&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            , c.LastName = tc.LastName;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Handling Type 2 attributes
      &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;Handling Type 2 is tricky. If a record is changed, we need to update the old record, setting the &lt;strong&gt;EndDate&lt;/strong&gt; as current date, and then insert a new record for it, with &lt;strong&gt;StartDate&lt;/strong&gt; as current date. See the code below;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;INSERT &lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; DimCustomer&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    (SourceCode, FirstName, LastName, MaritalStatus, Country&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , StartDate, EndDate)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; Modified.SourceCode, Modified.FirstName&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , Modified.LastName, Modified.MaritalStatus&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , Modified.Country, Modified.StartDate&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , Modified.EndDate&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    (MERGE &lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; dbo.DimCustomer c&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;USING&lt;/span&gt; dbo.TempDImCustomer tc&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; (c.SourceCode = tc.SourceCode)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;WHEN&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; MATCHED &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;THEN&lt;/span&gt; INSERT&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            (SourceCode, FirstName, LastName, MaritalStatus, Country&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            , StartDate, EndDate)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;VALUES&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            (tc.SourceCode, tc.FirstName, tc.LastName, tc.MaritalStatus, tc.Country&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            , GetDate(), &lt;span style="color: #006080"&gt;'12/31/9999'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;WHEN&lt;/span&gt; MATCHED &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;AND&lt;/span&gt; c.EndDate = &lt;span style="color: #006080"&gt;'12/31/9999'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;AND&lt;/span&gt; (c.MaritalStatus != tc.MaritalStatus&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;OR&lt;/span&gt; c.Country != tc.Country)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;THEN&lt;/span&gt; &lt;span style="color: #0000ff"&gt;UPDATE&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; c.EndDate = getDate()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;OUTPUT&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            $&lt;span style="color: #0000ff"&gt;Action&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Action&lt;/span&gt;, tc.SourceCode, tc.FirstName, tc.LastName&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            , tc.MaritalStatus, tc.Country&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            , &lt;span style="color: #006080"&gt;'10/28/2010'&lt;/span&gt; StartDate, &lt;span style="color: #006080"&gt;'12/31/9999'&lt;/span&gt; EndDate) &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; Modified&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;WHERE&lt;/span&gt; Modified.&lt;span style="color: #0000ff"&gt;Action&lt;/span&gt; = &lt;span style="color: #006080"&gt;'UPDATE'&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;See the inner MERGE first. With first &lt;strong&gt;NOT MATCHED&lt;/strong&gt; section, it inserts new records. Next is for finding &lt;strong&gt;MACTHED&lt;/strong&gt; and Type 2 changes. Note that the check is done only on latest records (&lt;strong&gt;EndDate = ‘12/31/9999’&lt;/strong&gt;). If found, &lt;strong&gt;EndDate &lt;/strong&gt;is updated and records are returned as a OUTPUT of the MERGE. This output is captured by outer INSERT statement and inserts them as new records. Done!&lt;/p&gt;

&lt;p align="justify"&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Please do test both approaches before deciding the technique. If the data set is large, it would be better to use MERGE instead of SSIS SCD component.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-3345211944719154246?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/3345211944719154246/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=3345211944719154246&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3345211944719154246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3345211944719154246'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/11/ssis-replacing-slowly-changing.html' title='SSIS: Replacing Slowly Changing Dimension (SCD) wizard with the MERGE statement'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_p0AH7nWLB-k/TM6VhBJ1iyI/AAAAAAAAAtg/WT5b_AqHI84/s72-c/table_thumb2.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-5548789148845404996</id><published>2010-10-28T22:33:00.001-07:00</published><updated>2010-10-28T22:33:25.625-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Degenerated Dimension'/><category scheme='http://www.blogger.com/atom/ns#' term='Data Warehousing'/><title type='text'>Dimension has no attributes…Can I make it as Degenerated Dimension?</title><content type='html'>&lt;p align="justify"&gt;One of my friends recently came up with an interesting topic where he has faced an issue with his Data Warehouse design related to Insurance industry. He has come across a situation where he needs to build a dimension for Insurance Claim numbers that holds ONLY claim numbers. He has already build other related dimensions such as Customer and Product, and has built the Fact table too.&lt;/p&gt;  &lt;p align="justify"&gt;This particular Insurance Claim number is one of the attributes set at grain level of the fact. In addition to that, no common claim numbers, all are unique, and number of claim numbers are grown at the same rate that fact table grows. He wanted my opinion on this, thought degenerate the claim number without maintaining a separate dimension. The below image explains what I suggested;   &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_p0AH7nWLB-k/TMpcn8yo8BI/AAAAAAAAAtU/cCxflXmrDhM/s1600-h/diagram1%5B4%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="diagram1" border="0" alt="diagram1" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TMpcpCHM4UI/AAAAAAAAAtY/1L3-B8FOdYU/diagram1_thumb%5B2%5D.png?imgmax=800" width="406" height="596" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;As you see, first diagram has a dimension for maintaining claim numbers. The second has no dimension for claim numbers and claim number has been added to the Fact table. The best option I see is, making it as a degenerated dimension because;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Number of records in the ClaimNumber dimension grows at the same rate that Fact table grows.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Claim number has no other descriptive attributes.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Claim number does not exist outside the transaction (the claim).&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;I am facing a similar issue on Banking related DW, the Fact focuses on Deposits and the transaction related deposits contain Comments. Comments are not available for all transactions and they are not common among transactions too. I do not like to see NULLs in my Fact table but thought to degenerate into Fact table. I wish I could argue on this with someone……… :)&lt;/p&gt;  &lt;p align="justify"&gt;If you need to read more on Degenerated Dimension, read &lt;strong&gt;Kimballl Design Tip #46&lt;/strong&gt; at &lt;a href="http://www.rkimball.com/html/designtipsPDF/DesignTips2003/KimballDT46AnotherLook.pdf"&gt;http://www.rkimball.com/html/designtipsPDF/DesignTips2003/KimballDT46AnotherLook.pdf&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-5548789148845404996?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/5548789148845404996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=5548789148845404996&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5548789148845404996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5548789148845404996'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/10/dimension-has-no-attributescan-i-make.html' title='Dimension has no attributes…Can I make it as Degenerated Dimension?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_p0AH7nWLB-k/TMpcpCHM4UI/AAAAAAAAAtY/1L3-B8FOdYU/s72-c/diagram1_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-116642217045946459</id><published>2010-10-26T04:16:00.001-07:00</published><updated>2010-10-26T04:16:23.807-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008 R2'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle'/><title type='text'>Is Microsoft's SQL Server really cheaper than Oracle?</title><content type='html'>&lt;p align="justify"&gt;Sean McCown has written an article on “&lt;a href="http://www.networkworld.com/community/node/63390" target="_blank"&gt;http://www.networkworld.com/community/node/63390&lt;/a&gt;”. Good article, worth to read.&lt;/p&gt;  &lt;p align="justify"&gt;Do not forget to read comments too.   &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-116642217045946459?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/116642217045946459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=116642217045946459&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/116642217045946459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/116642217045946459'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/10/is-microsoft-sql-server-really-cheaper.html' title='Is Microsoft&amp;#39;s SQL Server really cheaper than Oracle?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-8933898603333551365</id><published>2010-10-25T23:06:00.001-07:00</published><updated>2010-10-25T23:06:27.650-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TCP IP'/><category scheme='http://www.blogger.com/atom/ns#' term='SSIS'/><category scheme='http://www.blogger.com/atom/ns#' term='Named Pipe'/><title type='text'>SSIS Error: Named Pipes Provider: The specified network name is no longer available.</title><content type='html'>&lt;p align="justify"&gt;A perfectly working package suddenly throws an error;&lt;/p&gt;  &lt;p align="justify"&gt;“&lt;em&gt;&lt;font color="#ff0000"&gt;[Lookup for - Pending Duration [7825]] Error: SSIS Error Code DTS_E_OLEDBERROR.&amp;#160; An OLE DB error has occurred. Error code: 0x80004005.       &lt;br /&gt;An OLE DB record is available.&amp;#160; Source: &amp;quot;Microsoft SQL Server Native Client 10.0&amp;quot;&amp;#160; Hresult: 0x80004005&amp;#160; Description: &amp;quot;Communication link failure&amp;quot;.        &lt;br /&gt;An OLE DB record is available.&amp;#160; Source: &amp;quot;Microsoft SQL Server Native Client 10.0&amp;quot;&amp;#160; Hresult: 0x80004005&amp;#160; Description: &amp;quot;Named Pipes Provider: The specified network name is no longer available.        &lt;br /&gt;&amp;quot;.&lt;/font&gt;&lt;/em&gt;”&lt;/p&gt;  &lt;p align="justify"&gt;This package is a kind of complex one, it contains three Data Flow tasks and couple of other tasks. It basically loads a Fact Table in one of Data Warehouses, goes through set of LookUps which have set for Dimension tables.&lt;/p&gt;  &lt;p align="justify"&gt;The error raises with one of the LookUps. The lookUp is supposed to go through around 40,000 records but stops at around 6,000, throwing the error. Once this started giving the issue, the only difference we can thought about current execution and early executions is, the amount of data, it has been increased.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Solving the issue by changing the protocol TCPIP&lt;/font&gt;&lt;/strong&gt;    &lt;br /&gt;After searching for solutions, going through many posts, based on some recommendations, we decided to force SSIS to use TCPIP instead of Named Pipes. We disabled the Named Pipe protocol in SQL Server through SQL Server Configuration Manager. We did the same with where we run the package. Finally we ran the package and ended up with same point;&lt;/p&gt;  &lt;p align="justify"&gt;“&lt;em&gt;&lt;font color="#ff0000" size="2"&gt;[Lookup for - Pending Duration [7825]] Error: SSIS Error Code DTS_E_OLEDBERROR.&amp;#160; An OLE DB error has occurred. Error code: 0x80004005.       &lt;br /&gt;An OLE DB record is available.&amp;#160; Source: &amp;quot;Microsoft SQL Server Native Client 10.0&amp;quot;&amp;#160; Hresult: 0x80004005&amp;#160; Description: &amp;quot;Login timeout expired&amp;quot;.        &lt;br /&gt;An OLE DB record is available.&amp;#160; Source: &amp;quot;Microsoft SQL Server Native Client 10.0&amp;quot;&amp;#160; Hresult: 0x80004005&amp;#160; Description: &amp;quot;A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.&amp;quot;.        &lt;br /&gt;An OLE DB record is available.&amp;#160; Source: &amp;quot;Microsoft SQL Server Native Client 10.0&amp;quot;&amp;#160; Hresult: 0x80004005&amp;#160; Description: &amp;quot;TCP Provider: Only one usage of each socket address (protocol/network address/port) is normally permitted.        &lt;br /&gt;&amp;quot;.&lt;/font&gt;&lt;/em&gt;”&lt;/p&gt;  &lt;p align="justify"&gt;We realized that the issue is not exactly related to protocols used by the package hence, went through some of the implementations we have done where we have slightly derailed the track of standardization. One implementation was related to transactions, where we had used explicit BEGIN TRAN and COMMIT TRAN to control the transactions without using the built-in facility. This type of implementation has been explained &lt;a href="http://consultingblogs.emc.com/jamiethomson/archive/2005/08/20/SSIS-Nugget_3A00_-RetainSameConnection-property-of-the-OLE-DB-Connection-Manager.aspx" target="_blank"&gt;here&lt;/a&gt; if you need to know how to do it. The reasons for using this is arguable but some of them were, MS DTC issues, Firewalls, and company policies.&lt;/p&gt;  &lt;p align="justify"&gt;In order to set the transaction like above, we need to set the &lt;strong&gt;RetailSameConnection&lt;/strong&gt; as &lt;strong&gt;True&lt;/strong&gt; in OLE DB connection. That was the culprit. Since this forces SSIS to maintain one connection through out the package execution, it seems that using one connection for all lookups is not efficient. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Solving the issue&lt;/font&gt;&lt;/strong&gt;    &lt;br /&gt;One easiest way to solve the issue is, adding &lt;strong&gt;Timeout=0&lt;/strong&gt; to the connection string. But this slows down the package execution vastly, though it succeeds. The next way is, handling the transactions in different way. We thought to use the second way because the time takes for the first one is not acceptable.&lt;/p&gt;  &lt;p align="justify"&gt;The above mentioned errors may occur for some other reasons too but this could be the one if you have already face :).&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-8933898603333551365?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/8933898603333551365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=8933898603333551365&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/8933898603333551365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/8933898603333551365'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/10/ssis-error-named-pipes-provider.html' title='SSIS Error: Named Pipes Provider: The specified network name is no longer available.'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-4431457167386409661</id><published>2010-10-25T01:22:00.001-07:00</published><updated>2010-10-25T01:22:06.642-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Query Plan'/><title type='text'>Plan Caching in SQL Server 2008</title><content type='html'>&lt;p align="justify"&gt;I got many questions on the post I published “&lt;a href="http://dinesql.blogspot.com/2010/10/do-we-need-to-recompile-stored.html"&gt;Do we need to recompile Stored Procedures when an index is added or parameter value is vary greatly?&lt;/a&gt;”, seems many are interesting on it. While looking for some info related to it, I found an interesting technical article that speaks about Plan Caching written by Greg Low. Read it, it explains everything well;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee343986.aspx"&gt;http://msdn.microsoft.com/en-us/library/ee343986.aspx&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-4431457167386409661?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/4431457167386409661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=4431457167386409661&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4431457167386409661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/4431457167386409661'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/10/plan-caching-in-sql-server-2008.html' title='Plan Caching in SQL Server 2008'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-7502720244413780165</id><published>2010-10-21T23:42:00.001-07:00</published><updated>2010-10-21T23:42:29.790-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Query Plan'/><title type='text'>Do we need to recompile Stored Procedures when an index is added or parameter value is vary greatly?</title><content type='html'>&lt;p align="justify"&gt;While Preethi was presenting his presentation on Query Plans at the SQL Server Sri Lanka User Group meeting, he showed a situation where query plan gets recompiled when a value set for WHERE clause is vary. Although it recompiles, I doubt that it will not be the same if the query is a parameterized query with a stored procedure. There were couple of arguments on this favoring both sides; thought to test it and see.&lt;/p&gt;  &lt;p align="justify"&gt;Let me take simple two queries. The queries below are same except the value passed for the WHERE clause.&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.SalesOrderDetail &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;WHERE&lt;/span&gt; SalesOrderDetailID &amp;lt;= 1&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.SalesOrderDetail &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;WHERE&lt;/span&gt; SalesOrderDetailID &amp;lt;= 1000&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;SQL Server selects one plan for the first one but it does not use the same for the next though it is same.
  &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TMExqtjdjZI/AAAAAAAAAso/kyCrDphRyHY/s1600-h/plan1%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="plan1" border="0" alt="plan1" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TMExvjMRRhI/AAAAAAAAAss/QXlaR0q6oWg/plan1_thumb%5B1%5D.png?imgmax=800" width="411" height="216" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p align="justify"&gt;This shows clearly that the statement has been recompiled since the value was different. But this is not going to happen if the logic is implemented with a stored procedure;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROC&lt;/span&gt; GetOrderDetails @Number &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.SalesOrderDetail &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;WHERE&lt;/span&gt; SalesOrderDetailID &amp;lt;= @Number&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;The plan for the procedure will be generated at the first execution. Once generated, the generated plan will be used for next executions even though the value of parameters are vary greatly. See the code below;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXEC&lt;/span&gt; GetOrderDetails 1&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXEC&lt;/span&gt; GetOrderDetails 1000&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TMEx-ubjFtI/AAAAAAAAAsw/pWMfY9-hD-M/s1600-h/plan2%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="plan2" border="0" alt="plan2" src="http://lh4.ggpht.com/_p0AH7nWLB-k/TMEyGtK4O0I/AAAAAAAAAs0/FX3MOjocI0c/plan2_thumb%5B1%5D.png?imgmax=800" width="403" height="216" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;You can see that the same plan which was generated for the first execution has been used for second execution even though it is not the best plan for the value 1000. All we have to remember is, stored procedures are not getting re-compiled when values of parameters are vary. If you expect a situation like this, use &lt;strong&gt;WITH RECOMPILE&lt;/strong&gt; with the stored procedure. This instructs SQL Server to not to stored the plan generated, hence it creates a plan at every execution. If it is rare, use &lt;strong&gt;WITH RECOMPILE&lt;/strong&gt; when you call the stored procedure. This creates the plan again when it is executed.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;ALTER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROC&lt;/span&gt; GetOrderDetails @Number &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; RECOMPILE&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- OR&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXEC&lt;/span&gt; GetOrderDetails 1000&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; RECOMPILE&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;The next is whether the stored procedure gets recompiled when an index is added to a table used in it. See what BOL says;
  &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TMEyK1JXfSI/AAAAAAAAAs4/Rf8lHfegfdI/s1600-h/BOL%5B5%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="BOL" border="0" alt="BOL" src="http://lh3.ggpht.com/_p0AH7nWLB-k/TMEyOYPQMnI/AAAAAAAAAtA/R4GH7rszIxE/BOL_thumb%5B3%5D.png?imgmax=800" width="408" height="292" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p align="justify"&gt;It clearly says that the stored procedure will not get recompiled when an index is added to a table used with it. But what I found is the opposite of it. Sometime one of the statements gets compiled, sometime the entire stored procedure gets compiled. This is how I tested;&lt;/p&gt;

&lt;p align="justify"&gt;This code creates a new table and then creates a stored procedure. The execution of the stored procedure creates a plan and it is used for subsequent execution.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; *&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; TempSalesOrderDetail&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.SalesOrderDetail&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROC&lt;/span&gt; GetTempOrderDetails&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; SalesOrderDetailID &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; TempSalesOrderDetail &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;ORDER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;BY&lt;/span&gt; SalesOrderDetailID&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXEC&lt;/span&gt; GetTempOrderDetails &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;Here is the generated plan for it.
  &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_p0AH7nWLB-k/TMEyQJiUGkI/AAAAAAAAAtE/siHUQJ44kBI/s1600-h/plan3%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="plan3" border="0" alt="plan3" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TMEyRXZ6XdI/AAAAAAAAAtI/vbja8CVBGI8/plan3_thumb%5B1%5D.png?imgmax=800" width="404" height="117" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;As per the BOL, stored procedure does not get recompiled when an index is added…&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;INDEX&lt;/span&gt; IX_1 &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; TempSalesOrderDetail (SalesOrderDetailID)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXEC&lt;/span&gt; GetTempOrderDetails &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;Here is the plan now.
  &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_p0AH7nWLB-k/TMEyS6-G9sI/AAAAAAAAAtM/083-RVsPN9s/s1600-h/plan4%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="plan4" border="0" alt="plan4" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TMEyUQOvjRI/AAAAAAAAAtQ/OxfzuuVTvAU/plan4_thumb%5B1%5D.png?imgmax=800" width="407" height="111" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p align="justify"&gt;Now the plan is different, means the stored procedure has been recompiled. There might be a situation where the behavior as same as BOL says, will see whether we can find a such situation.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-7502720244413780165?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/7502720244413780165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=7502720244413780165&amp;isPopup=true' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7502720244413780165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/7502720244413780165'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/10/do-we-need-to-recompile-stored.html' title='Do we need to recompile Stored Procedures when an index is added or parameter value is vary greatly?'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_p0AH7nWLB-k/TMExvjMRRhI/AAAAAAAAAss/QXlaR0q6oWg/s72-c/plan1_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-5150187365118887354</id><published>2010-10-21T09:40:00.001-07:00</published><updated>2010-10-21T09:40:03.640-07:00</updated><title type='text'>TechInsights – Malaysia – Session Ratings</title><content type='html'>&lt;p align="justify"&gt;I just received ratings for sessions I delivered in Malaysia, glad to see that the sessions have been useful and valuable for participants. Ratings received are as follows;&lt;/p&gt;  &lt;p align="justify"&gt;Session: Strengthening DW/BI system loading   &lt;br /&gt;Overall Rating: 7.0&lt;/p&gt;  &lt;p align="justify"&gt;Session: Simplifying Master Data Management with SQL Server 2008 R2   &lt;br /&gt;Overall Rating: 6.8&lt;/p&gt;  &lt;p align="justify"&gt;Thanks for Ervin and Lilian for inviting me for &lt;a href="http://www.techinsights.my/" target="_blank"&gt;TechInsights&lt;/a&gt;, thanks for the support given by all event organizer, and thanks for all feedbacks from participants. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-5150187365118887354?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/5150187365118887354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=5150187365118887354&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5150187365118887354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/5150187365118887354'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/10/techinsights-malaysia-session-ratings.html' title='TechInsights – Malaysia – Session Ratings'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-6212460247295977868</id><published>2010-10-20T20:46:00.001-07:00</published><updated>2010-10-20T20:46:25.515-07:00</updated><title type='text'>Understanding Ownership Chaining and Impersonation</title><content type='html'>&lt;p align="justify"&gt;Being a DBA or DBE, understanding how Ownership Chains work and how impersonate another principal for changing the execution context are really important. This topic was discussed while I was conducting the course 6232A on last Saturday, thought to blog on it as it would be useful to you all.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;What is Ownership Chain?&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;When we perform an action with set of statements, objects used are accessed sequentially and this sequence is called as a Chain. Once the chain is established,&amp;#160; permissions on objects in the chain are evaluated differently, not the way it checks permissions when they are separately accessed. If the objects accessed in the chain are owned by a same owner, &lt;strong&gt;&lt;u&gt;Ownership Chain&lt;/u&gt; &lt;/strong&gt;is established. Within the ownership chain, SQL Server checks the permission for the first object and skips checking on others. This is the advantage of Ownership Chain because it offers slight performance benefit skipping permission checks on other objects. If SQL Server finds a broken ownership chain, it starts evaluating permission on them.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;What is Impersonation?&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;SQL Server Impersonation means, allowing to change the execution context with another principal. Simply, perform some actions (execute set of queries) using someone else privileges. This can be done explicitly by using the stand-alone EXECUTE AS statement or implicitly by using the EXECUTE AS clause on modules. &lt;/p&gt;  &lt;p align="justify"&gt;Let’s first check with Ownership Chaining and then go for Impersonation. I did this in a TestDatabase, you can do the same. The first code snippet creates two logins and two users. Note that SalesPerson is added to &lt;strong&gt;db_owner&lt;/strong&gt; role. &lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Create two logins&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; LOGIN SalesPerson &lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; PASSWORD = &lt;span style="color: #006080"&gt;'123'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;, CHECK_POLICY = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; LOGIN MarketingPerson &lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; PASSWORD = &lt;span style="color: #006080"&gt;'123'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;, CHECK_POLICY = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Create users for logins.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;USE&lt;/span&gt; TestDatabase&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; SalesPerson &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; LOGIN SalesPerson&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;sp_addrolemember &lt;span style="color: #006080"&gt;'db_owner'&lt;/span&gt;, &lt;span style="color: #006080"&gt;'SalesPerson'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; MarketingPerson &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; LOGIN MarketingPerson&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;GO&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;With next code you can see that Impersonation has been done explicitly using EXECUTE AS. What I do here is, impersonate SalesPerson and then create a schema and a table. Note that &lt;strong&gt;SalesPerson&lt;/strong&gt; becomes the owner of these objects.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; = &lt;span style="color: #006080"&gt;'SalesPerson'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;SCHEMA&lt;/span&gt; Sales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; Sales.Sales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Date&lt;/span&gt; &lt;span style="color: #0000ff"&gt;date&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , Amount money&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;REVERT&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;Next code impersonates &lt;strong&gt;MarketingPerson&lt;/strong&gt; and sees whether he can access the table &lt;strong&gt;Sales.Sales&lt;/strong&gt;. Since he has no permission on this table, error is thrown for SELECT query.&lt;/p&gt;

&lt;p align="justify"&gt;“&lt;font color="#ff0000"&gt;&lt;em&gt;The SELECT permission was denied on the object 'Sales', database 'TestDatabase', schema 'Sales'.&lt;/em&gt;&lt;/font&gt;”&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; = &lt;span style="color: #006080"&gt;'MarketingPerson'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.Sales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;REVERT&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;GO&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;Let’s check Ownership Chaining. With next code, &lt;strong&gt;SalesPerson&lt;/strong&gt; creates a stored procedure that returns data from &lt;strong&gt;Sales.Sales&lt;/strong&gt;, and he grants EXECUTE permission to &lt;strong&gt;MarketingPerson&lt;/strong&gt;.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; = &lt;span style="color: #006080"&gt;'SalesPerson'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROC&lt;/span&gt; Sales.GetSales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.Sales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GRANT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; Sales.GetSales &lt;span style="color: #0000ff"&gt;TO&lt;/span&gt; MarketingPerson&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;REVERT&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;We know that &lt;strong&gt;MarketingPerson&lt;/strong&gt; has no read permission on &lt;strong&gt;Sales.Sales&lt;/strong&gt; table but with next code, you can see that he can read the table through &lt;strong&gt;Sales.GetSales&lt;/strong&gt; procedure. &lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; = &lt;span style="color: #006080"&gt;'MarketingPerson'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- MarketingPerson can access the table&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- through the SP&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXEC&lt;/span&gt; Sales.GetSales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- This throws the same error&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.Sales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;REVERT&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;The reason for this is, the &lt;strong&gt;Ownership Chain&lt;/strong&gt;. As &lt;strong&gt;MarketingPerson &lt;/strong&gt;has EXECUTE permission, he can execute the SP. Although he has no permission on &lt;strong&gt;Sales.Sales&lt;/strong&gt;, SQL Server does not evaluate permission on it for &lt;strong&gt;MarketingPerson&lt;/strong&gt; because it is owned by the same owner who owns &lt;strong&gt;Sales.GetSales&lt;/strong&gt;. Note that we have not explicitly set owners for both &lt;strong&gt;Sales.GetSales&lt;/strong&gt; and &lt;strong&gt;Sales.Sales&lt;/strong&gt;, hence owners of them are considered as &lt;strong&gt;Sales&lt;/strong&gt; schema’s owner; &lt;strong&gt;SalesPerson&lt;/strong&gt;. Below code shows it;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; USER_NAME( OBJECTPROPERTY(OBJECT_ID(&lt;span style="color: #006080"&gt;'Sales.Sales'&lt;/span&gt;), &lt;span style="color: #006080"&gt;'OwnerId'&lt;/span&gt;))&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;If the SP contains an object owned by someone else, it breaks Ownership Chain. Let’s test this too. Below code adds a new table, note that no impersonation is established, so, it is created by dbo. Since it is under &lt;strong&gt;Sales&lt;/strong&gt; schema too, the owner of the schema (&lt;strong&gt;SalesPerson&lt;/strong&gt;) becomes the owner of the new table.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; Sales.SalesCommisions&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    SaleNumber &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , Amount money&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;Next, the code of the SP is altered by &lt;strong&gt;SalesPerson&lt;/strong&gt;. Now it contains both tables but still &lt;strong&gt;MarketingPerson&lt;/strong&gt; can execute the SP without any issues even though he has no permission on new table.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; = &lt;span style="color: #006080"&gt;'SalesPerson'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;ALTER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROC&lt;/span&gt; Sales.GetSales    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.Sales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.SalesCommisions&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;END&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;REVERT&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; = &lt;span style="color: #006080"&gt;'MarketingPerson'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Can see both tables&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXEC&lt;/span&gt; Sales.GetSales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Both statement throw errors&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.Sales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.SalesCommisions&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;REVERT&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;Still the Ownership Chain works. Let’s break it. Let’s change the owner of the new table &lt;strong&gt;Sales.SalesCommisions&lt;/strong&gt; as dbo.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;ALTER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AUTHORIZATION&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; &lt;span style="color: #0000ff"&gt;OBJECT&lt;/span&gt;::Sales.SalesCommisions &lt;span style="color: #0000ff"&gt;TO&lt;/span&gt; dbo&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;Now if &lt;strong&gt;MarketingPerson &lt;/strong&gt;executes the SP, he gets an error for &lt;strong&gt;Sales.SalesCommisions&lt;/strong&gt; table:

  &lt;br /&gt;”&lt;font color="#ff0000"&gt;&lt;em&gt;The SELECT permission was denied on the object 'SalesCommisions', database 'TestDatabase', schema 'Sales'.&lt;/em&gt;&lt;/font&gt;”&lt;/p&gt;

&lt;p align="justify"&gt;The reason is, the second object, &lt;strong&gt;Sales.SaleCommisions &lt;/strong&gt;is not owned by the same person who owns the SP, hence SQL Server checks and sees whether &lt;strong&gt;MarketingPerson &lt;/strong&gt;has permission on &lt;strong&gt;Sales.SaleCommissions&lt;/strong&gt;. &lt;/p&gt;

&lt;p align="justify"&gt;How can we let &lt;strong&gt;MarketingPerson&lt;/strong&gt; to execute the SP without giving explicit permission on &lt;strong&gt;Sales.SaleCommissions&lt;/strong&gt;? Impersonation is the answer. We can use EXECUTE AS explicitly with the stored procedure, instructing SQL Server to execute the stored procedure with someone else privileges without using CALLER’s privileges. See the code below;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USER&lt;/span&gt; = &lt;span style="color: #006080"&gt;'SalesPerson'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;ALTER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROC&lt;/span&gt; Sales.GetSales    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; &lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #006080"&gt;'SalesPerson'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.Sales&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.SalesCommisions&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;END&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;REVERT&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;Now if &lt;strong&gt;MarketingPerson &lt;/strong&gt;executes the SP, he will see the result without seeing an error because the execution context for the SP’s execution is set with &lt;strong&gt;SalesPerson&lt;/strong&gt; not with &lt;strong&gt;MarketingPerson&lt;/strong&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-6212460247295977868?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/6212460247295977868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=6212460247295977868&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/6212460247295977868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/6212460247295977868'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/10/understanding-ownership-chaining-and.html' title='Understanding Ownership Chaining and Impersonation'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-9005642731052382091</id><published>2010-10-04T18:30:00.001-07:00</published><updated>2010-10-04T18:30:42.262-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Business Intelligence'/><title type='text'>HP Business Intelligence Sizer for Microsoft SQL Server</title><content type='html'>&lt;p align="justify"&gt;One of the challenges in Business Intelligence solutions is sizing the infrastructure. Many go with various calculations and assumptions and decide the infrastructure but later find that the capacity selected is not sufficient. One reason could be, most try to define the required hardware spec at the planning or proposal stage, without considering the workloads and processing them. If you plan for HP box for your BI solution, you can use the HP Business Intelligence Sizer for determining the spec. It interviews you for gathering factors related to your solution and provides you a recommendation;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_p0AH7nWLB-k/TKp_vZjmFPI/AAAAAAAAAsg/e4GmIuETQ9o/s1600-h/HP%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="HP" border="0" alt="HP" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TKp_wP2GLBI/AAAAAAAAAsk/vABP6q1HuHc/HP_thumb%5B1%5D.png?imgmax=800" width="402" height="237" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;I feel that this is not for small type of BI solution and suitable for large-scale solutions but you can try and see.&lt;/p&gt;  &lt;p align="justify"&gt;Here is the link for downloading the tool: &lt;a href="http://h71019.www7.hp.com/activeanswers/us/en/sizers/microsoft-sql-bi.html"&gt;http://h71019.www7.hp.com/activeanswers/us/en/sizers/microsoft-sql-bi.html&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-9005642731052382091?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/9005642731052382091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=9005642731052382091&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/9005642731052382091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/9005642731052382091'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/10/hp-business-intelligence-sizer-for.html' title='HP Business Intelligence Sizer for Microsoft SQL Server'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_p0AH7nWLB-k/TKp_wP2GLBI/AAAAAAAAAsk/vABP6q1HuHc/s72-c/HP_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-3588978180687644896</id><published>2010-10-03T18:28:00.001-07:00</published><updated>2010-10-03T18:28:01.030-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Business Intelligence'/><category scheme='http://www.blogger.com/atom/ns#' term='Survey'/><title type='text'>Looking for a BI Product suite? Have a look on “The BI Survey 9”</title><content type='html'>&lt;p align="justify"&gt;Business Application Research Center – BARC publishes various types of survey reports; has published “&lt;strong&gt;The BI Verdict&lt;/strong&gt;”, the latest BI survey report that contains comprehensive collection of in-depth BI product evaluations and market analysis. Here is a quote from the site:&lt;/p&gt;  &lt;p align="justify"&gt;“The BI Survey 9 uncovers the truth about why real-world organizations select BI products, what they do with them, and why they eventually abandon them.&amp;#160; It also compares the leading products on the market across a number of key criteria such as performance, scalability and vendor support.”&lt;/p&gt;  &lt;p align="justify"&gt;You need to spend around USD 4995 for purchasing this survey. It will be worthwhile to spend for it if you are planning for buying a BI suite for your organization.&lt;/p&gt;  &lt;p align="justify"&gt;Here is the link: &lt;a href="http://www.bi-survey.com/home.html"&gt;http://www.bi-survey.com/home.html&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-3588978180687644896?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/3588978180687644896/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=3588978180687644896&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3588978180687644896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/3588978180687644896'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/10/looking-for-bi-product-suite-have-look.html' title='Looking for a BI Product suite? Have a look on “The BI Survey 9”'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-2724821570222157466</id><published>2010-09-30T18:17:00.001-07:00</published><updated>2010-09-30T18:21:03.146-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Reporting Services 2008 R2'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerPivot'/><category scheme='http://www.blogger.com/atom/ns#' term='PivotViewer'/><title type='text'>PivotViewer Extension for SQL Server Reporting Services</title><content type='html'>&lt;p align="justify"&gt;You might have already seen Microsoft Silverlight PivotViewer for Excel (see my &lt;a href="http://dinesql.blogspot.com/2010/07/microsoft-silverlight-pivotviewer-is.html" target="_blank"&gt;post&lt;/a&gt; on it). Just like that you are going to see PivotViewer for SSRS. Good news? Yes, but there is a bad news too, it is not yet available for downloading, it a kind of prototype, here how it goes;    &lt;br /&gt;    &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_p0AH7nWLB-k/TKU2e-t_ErI/AAAAAAAAAsY/jiJTJRJpqfM/s1600-h/pp%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="pp" border="0" alt="pp" src="http://lh5.ggpht.com/_p0AH7nWLB-k/TKU2t_b07XI/AAAAAAAAAsc/G-5fqDPZBP4/pp_thumb%5B1%5D.png?imgmax=800" width="402" height="306" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Anyway, have a look on &lt;a href="http://www.microsoft.com/sqlserver/tour/en/videos/pivot-viewer.aspx" target="_blank"&gt;this video&lt;/a&gt;, this shows it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-2724821570222157466?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/2724821570222157466/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=2724821570222157466&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/2724821570222157466'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/2724821570222157466'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/09/pivotviewer-extension-for-sql-server.html' title='PivotViewer Extension for SQL Server Reporting Services'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_p0AH7nWLB-k/TKU2t_b07XI/AAAAAAAAAsc/G-5fqDPZBP4/s72-c/pp_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-1619751365418385505</id><published>2010-09-29T18:26:00.001-07:00</published><updated>2010-09-29T18:26:13.196-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Service Pack'/><title type='text'>SQL Server 2008 Service Pack 2 is available for downloading</title><content type='html'>&lt;p align="justify"&gt;SQL Server 2008 SP 2 is available for downloading now. Enhancements includes;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;15K partitioning Improvement &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Reporting Services in SharePoint Integrated Mode &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;SQL Server 2008 R2 Application and Multi-Server Management Compatibility with SQL Server 2008 &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Data-tier Application (DAC) Support&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt; Read more info on this and download from &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8fbfc1de-d25e-4790-88b5-7dda1f1d4e17&amp;amp;displaylang=en" target="_blank"&gt;here&lt;/a&gt;.    &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3739073232502260520-1619751365418385505?l=dinesql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dinesql.blogspot.com/feeds/1619751365418385505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3739073232502260520&amp;postID=1619751365418385505&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/1619751365418385505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3739073232502260520/posts/default/1619751365418385505'/><link rel='alternate' type='text/html' href='http://dinesql.blogspot.com/2010/09/sql-server-2008-service-pack-2-is.html' title='SQL Server 2008 Service Pack 2 is available for downloading'/><author><name>Dinesh Priyankara</name><uri>http://www.blogger.com/profile/03528311189201964690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_p0AH7nWLB-k/TTx0FHn9h9I/AAAAAAAAAxo/CeRWWEadGss/s220/1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3739073232502260520.post-2367107454805826253</id><published>2010-09-29T18:10:00.001-07:00</published><updated>2010-09-29T18:10:22.449-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Table Variable'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Cardinality'/><category scheme='http://www.blogger.com/atom/ns#' term='Estimated Number of Rows'/><title type='text'>Table variable slower than Temporary table???</title><content type='html'>&lt;p align="justify"&gt;I used to use table variables when the resultset is smaller and want to hold it temporarily. The main reason for this selection is, data manipulation with table variables is faster than manipulation with temporary tables when the container contains a smaller amount of data. There were some instances, specially on JOINs, table variables show slowness, have been thinking to investigate but had no time. Thought start investigating on it again when I saw &lt;a href="http://blogs.msdn.com/b/psssql/archive/2010/08/24/query-performance-and-table-variables.aspx" target="_blank"&gt;this post&lt;/a&gt; of Jack Li.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Simple Test&lt;/font&gt;&lt;/strong&gt;     &lt;br /&gt;Let me start with an example, similar to an issue I had. The following code creates a table variable and loads sales data into it. Later, the table variable joins with a permanent table, to get a resultset. Note that there is no logic on the query, this is just for testing. Turn &lt;strong&gt;Include Actual Execution Plan&lt;/strong&gt; on and run the query below.&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;DECLARE&lt;/span&gt; @TestTable &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    SalesOrderId &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , SalesOrderDetailID &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , LineTotal money &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , &lt;span style="color: #0000ff"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: #0000ff"&gt;KEY&lt;/span&gt; (SalesOrderId, SalesOrderDetailID)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;INSERT &lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; @TestTable&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; SalesOrderID&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , SalesOrderDetailID&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    , LineTotal &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; Sales.SalesOrderDetail&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; t.SalesOrderId, s.UnitPrice&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; @TestTable t&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;INNER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;JOIN&lt;/span&gt; Sales.SalesOrderDetail s&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; t.SalesOrderId = s.SalesOrderID&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;AND&lt;/span&gt; t.SalesOrderDetailID = s.SalesOrderDetailID&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_p0AH7nWLB-k/TKPjPJbJsLI/AAAAAAAAAsA/aPujtJxmpjI/s1600-h/plan3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="plan" border="0" alt="plan" src="http://lh6.ggpht.com/_p0AH7nWLB-k/TKPjSJSOb7I/AAAAAAAAAsE/weugg2fBjAo/plan_thumb1.png?imgmax=800" width="406" height="262" /&gt;&lt;/a&gt; 

  &lt;br /&gt;Now investigate the execution plan for SELECT query. See &lt;strong&gt;Estimated Number of Rows,&lt;/strong&gt; it shows as 1 which is incorrect. This causes &lt;strong&gt;Optimizer&lt;/strong&gt; to use &lt;strong&gt;Nested Loops&lt;/strong&gt; instead of &lt;strong&gt;Merge Join &lt;/strong&gt;and reduces the performance of data retrieval.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Is Merge Join better than Nested Loops?&lt;/font&gt;&lt;/strong&gt; 

  &lt;br /&gt;According to the BOL, Query Optimizer determines the cost of query plan and selects based on two factors;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The total number of rows processed at each level of a query plan, referred to as the cardinality of the plan.
