<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblogcasts.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">SQL Blog - Pieter van Maasdam, Macaw</title><subtitle type="html">SSIS, SSAS, SSRS &amp;amp; other SQL-things I come across...</subtitle><id>http://sqlblogcasts.com/blogs/repieter/atom.aspx</id><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/repieter/default.aspx" /><link rel="self" type="application/atom+xml" href="http://sqlblogcasts.com/blogs/repieter/atom.aspx" /><generator uri="http://communityserver.org" version="3.1.20917.1142">Community Server</generator><updated>2007-11-28T15:03:00Z</updated><entry><title>SSIS - Range lookups</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/repieter/archive/2011/02/04/ssis-range-lookups.aspx" /><id>http://sqlblogcasts.com/blogs/repieter/archive/2011/02/04/ssis-range-lookups.aspx</id><published>2011-02-04T12:41:00Z</published><updated>2011-02-04T12:41:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When developing an ETL solution in SSIS we sometimes need to do range lookups in SSIS. Several solutions for this can be found on the internet, but now we have built another solution which I would like to share, since it&amp;#39;s pretty easy to implement and the performance is fast.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can download the &lt;a title="RangeLookup.zip" href="http://sqlblogcasts.com/blogs/repieter/RangeLookup.zip"&gt;sample package&lt;/a&gt; to see how it works. Make sure you have the AdventureWorks2008R2 and AdventureWorksDW2008R2 databases installed. (Apologies for the layout of this blog, I don&amp;#39;t do this too often :))&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To give a little bit more information about the example, this is basically what is does: we load a facttable and do an SCD type 2 lookup operation of the Product dimension. This is done with a script component.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;First we query the Data warehouse to create the lookup dataset. The query that is used for that is:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;SELECT&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ProductKey]&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,[ProductAlternateKey]&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,[StartDate]&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,ISNULL([EndDate], &amp;#39;9999-01-01&amp;#39;) AS EndDate&lt;/p&gt;
&lt;p&gt;FROM [DimProduct]&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The output of this query is stored in a DataTable:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;string lookupQuery = @&amp;quot;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ProductKey]&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,[ProductAlternateKey]&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,[StartDate]&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,ISNULL([EndDate], &amp;#39;9999-01-01&amp;#39;) AS EndDate&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM [DimProduct]&amp;quot;;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OleDbCommand oleDbCommand = new OleDbCommand(lookupQuery, _oleDbConnection);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OleDbDataAdapter adapter = new OleDbDataAdapter(oleDbCommand);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _dataTable = new DataTable();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; adapter.Fill(_dataTable);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now that the dimension data is stored in the DataTable we use the following method to do the actual lookup:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;public int RangeLookup(string businessKey, DateTime lookupDate)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // set default return value (Unknown)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int result = -1;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataRow[] filteredRows;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filteredRows = _dataTable.Select(string.Format(&amp;quot;ProductAlternateKey = &amp;#39;{0}&amp;#39;&amp;quot;, businessKey));&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; filteredRows.Length; i++)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // check if the lookupdate is found between the startdate and enddate of any of the records&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (lookupDate &amp;gt;= (DateTime)filteredRows[i][2] &amp;amp;&amp;amp; lookupDate &amp;lt; (DateTime)filteredRows[i][3])&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = (filteredRows[i][0] == null) ? -1 : (int)filteredRows[i][0];&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filteredRows = null;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return result;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This method is executed for every row that passes the script component. This is implemented in the ProcessInputRow method&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;public override void Input0_ProcessInputRow(Input0Buffer Row)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Perform the lookup operation on the current row and put the value in the Surrogate Key Attribute&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Row.ProductKey = RangeLookup(Row.ProductNumber, Row.OrderDate);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now what actually happens?!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1. Every record passes the business key and the orderdate to the RangeLookup method.&lt;/li&gt;
&lt;li&gt;2. The DataTable is then filtered on the business key of the current record. The output is stored in a DataRow [] object.&lt;/li&gt;
&lt;li&gt;3. We loop over the DataRow[] object to see where the orderdate meets the following expression:&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;(lookupDate &amp;gt;= (DateTime)filteredRows[i][2] &amp;amp;&amp;amp; lookupDate &amp;lt; (DateTime)filteredRows[i][3])&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;4. When the expression returns true (so where the data is between the Startdate and the EndDate), the surrogate key of the dimension record is returned&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We have done some testing with this solution and it works great for us. Hope others can use this example to do their range lookups.&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=15337" width="1" height="1"&gt;</content><author><name>Repieter</name><uri>http://sqlblogcasts.com/members/Repieter.aspx</uri></author><category term="SSIS 2008 Range Lookup" scheme="http://sqlblogcasts.com/blogs/repieter/archive/tags/SSIS+2008+Range+Lookup/default.aspx" /></entry><entry><title>SSIS 2008 - Rowcounts using the script component</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/repieter/archive/2010/01/25/ssis-2008-rowcounts-using-the-script-component.aspx" /><id>http://sqlblogcasts.com/blogs/repieter/archive/2010/01/25/ssis-2008-rowcounts-using-the-script-component.aspx</id><published>2010-01-25T10:18:00Z</published><updated>2010-01-25T10:18:00Z</updated><content type="html">&lt;p&gt;I have been using the Rowcount Component for some time now. The thing I didn&amp;#39;t like about it, is that I had to create an SSIS variable for every flow in the Data Flow Task. For example:&amp;nbsp;when extracting data we sometimes have more than&amp;nbsp;30 tables in a data flow.&amp;nbsp;So, I have been trying to find a more&amp;nbsp;flexible way to add rowcounts to my packages, without having to create a lot of new&amp;nbsp;variables.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s&amp;nbsp;an&amp;nbsp;example of what I came up with&amp;nbsp;(It&amp;#39;s not ready to be used in production environments by the way):&lt;/p&gt;
&lt;p&gt;&lt;img border="0" alt="Rowcount controlflow" src="http://sqlblogcasts.com/blogs/repieter/Images/RCControlFlow.png" width="338" height="265" /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I created an SSIS package variable of datatype Object named RowcountList. In the first Script Task, i initialize it by assigning an ArrayList to it. Next step is in the data flow task:&lt;/p&gt;
&lt;p&gt;&lt;img border="0" alt="Rowcount dataflow" src="http://sqlblogcasts.com/blogs/repieter/Images/RCDataFlow.png" width="338" height="265" /&gt;&lt;/p&gt;
&lt;p&gt;In the Script component I use an integer to count the rows. Then, in the PostExecute method I create an ArrayList based on the RowcountList variable. Then, I add the name of the script component combined with the rowcount to the ArrayList and store that in the SSIS variable RowcountList.&lt;/p&gt;
&lt;p&gt;Finally, in the last Script Task I iterate through the ArrayList and store the&amp;nbsp;rowcounts in a custom logging table. Now,&amp;nbsp;it seems to me this is a good way to do the rowcounts, but I&amp;#39;m very curious if other people have tried to do this and maybe have found a better way.&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12918" width="1" height="1"&gt;</content><author><name>Repieter</name><uri>http://sqlblogcasts.com/members/Repieter.aspx</uri></author><category term="logging" scheme="http://sqlblogcasts.com/blogs/repieter/archive/tags/logging/default.aspx" /><category term="script component" scheme="http://sqlblogcasts.com/blogs/repieter/archive/tags/script+component/default.aspx" /><category term="SSIS" scheme="http://sqlblogcasts.com/blogs/repieter/archive/tags/SSIS/default.aspx" /></entry><entry><title>SSRS -Report execution failed. Solution: SSPI=NTLM</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/repieter/archive/2009/11/17/ssrs-report-execution-failed-solution-sspi-ntlm.aspx" /><id>http://sqlblogcasts.com/blogs/repieter/archive/2009/11/17/ssrs-report-execution-failed-solution-sspi-ntlm.aspx</id><published>2009-11-17T12:55:00Z</published><updated>2009-11-17T12:55:00Z</updated><content type="html">&lt;p&gt;When executing&amp;nbsp;reports (Reporting Services 2008)&amp;nbsp;with Analysis Services 2008&amp;nbsp;as a source&amp;nbsp;I sometimes get an error saying: &amp;quot;Query execution failed for...&amp;quot;. The problem seemed to have something to do with large amounts of data (just guessing this...)&lt;/p&gt;
&lt;p&gt;To fix this error we had to add SSPI=NTLM to the connectionstring:&lt;/p&gt;
&lt;p&gt;Data Source=MyServer;Initial Catalog=MySSASDB;&lt;strong&gt;SSPI=NTLM;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m glad it&amp;#39;s working now, although I don&amp;#39;t understand what it actually does...&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12544" width="1" height="1"&gt;</content><author><name>Repieter</name><uri>http://sqlblogcasts.com/members/Repieter.aspx</uri></author><category term="SSRS 2008" scheme="http://sqlblogcasts.com/blogs/repieter/archive/tags/SSRS+2008/default.aspx" /><category term="Reporting Services 2008" scheme="http://sqlblogcasts.com/blogs/repieter/archive/tags/Reporting+Services+2008/default.aspx" /></entry><entry><title>SSAS 2008 - Connection from Excel</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/repieter/archive/2009/03/03/ssas-2008-connection-from-excel.aspx" /><id>http://sqlblogcasts.com/blogs/repieter/archive/2009/03/03/ssas-2008-connection-from-excel.aspx</id><published>2009-03-03T12:31:00Z</published><updated>2009-03-03T12:31:00Z</updated><content type="html">&lt;p&gt;I had some trouble connecting to an SSAS 2008 cube with Excel 2007. The problem was that Windows Firewall blocked the connection. A colleague of mine pointed out that you need to open 2 tcp ports on the server: 2382 and 2383. That did the trick.&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11401" width="1" height="1"&gt;</content><author><name>Repieter</name><uri>http://sqlblogcasts.com/members/Repieter.aspx</uri></author><category term="SSAS 2008 Excel" scheme="http://sqlblogcasts.com/blogs/repieter/archive/tags/SSAS+2008+Excel/default.aspx" /></entry><entry><title>SQL - Wrong results in Isoweek function</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/repieter/archive/2009/02/24/sql-wrong-results-in-isoweek-function.aspx" /><id>http://sqlblogcasts.com/blogs/repieter/archive/2009/02/24/sql-wrong-results-in-isoweek-function.aspx</id><published>2009-02-24T12:25:00Z</published><updated>2009-02-24T12:25:00Z</updated><content type="html">&lt;div&gt;See my previous post (&lt;a href="http://sqlblogcasts.com/blogs/repieter/archive/2009/02/24/sql2008-isoweek-in-datepart-function.aspx"&gt;http://sqlblogcasts.com/blogs/repieter/archive/2009/02/24/sql2008-isoweek-in-datepart-function.aspx&lt;/a&gt;)&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;In our organisation we use the ISOweek function to determine weeknumbers for a given date.&amp;nbsp;This function&amp;nbsp;appears to be&amp;nbsp;dependant of the language setting (@@DATEFIRST)&amp;nbsp;on the SQL Server. For example: January 5, 2009 should return weeknumber 2, but since the language is set to us_english&amp;nbsp;it returns weeknumber 1 for the given date. Since the weeknumber returned by this function is not correct, we needed another solution.&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;We found&amp;nbsp;another sql-function&amp;nbsp;that checks&amp;nbsp;the DATEFIRST setting before it calculates the weeknumbers:&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;a href="http://www.rmjcs.com/SQLServer/TSQLFunctions/ISOWeekNumber/tabid/207/language/en-GB/Default.aspx"&gt;http://www.rmjcs.com/SQLServer/TSQLFunctions/ISOWeekNumber/tabid/207/language/en-GB/Default.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;This gave us the expected result.&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11382" width="1" height="1"&gt;</content><author><name>Repieter</name><uri>http://sqlblogcasts.com/members/Repieter.aspx</uri></author><category term="SQL" scheme="http://sqlblogcasts.com/blogs/repieter/archive/tags/SQL/default.aspx" /></entry><entry><title>SQL2008 - IsoWeek in Datepart function</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/repieter/archive/2009/02/24/sql2008-isoweek-in-datepart-function.aspx" /><id>http://sqlblogcasts.com/blogs/repieter/archive/2009/02/24/sql2008-isoweek-in-datepart-function.aspx</id><published>2009-02-24T07:01:00Z</published><updated>2009-02-24T07:01:00Z</updated><content type="html">&lt;p&gt;To calculate the correct weeknumber I always used the IsoWeek function (found&amp;nbsp;here: &lt;a href="http://msdn.microsoft.com/en-us/library/aa258261(SQL.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/aa258261(SQL.80).aspx&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;In SQL 2008 this function is&amp;nbsp;available in&amp;nbsp;the DATEPART function:&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;SELECT &lt;/font&gt;&lt;font color="#ff00ff" size="2"&gt;DATEPART&lt;/font&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;font size="2"&gt;wk&lt;/font&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;&amp;#39;4 jan 2009&amp;#39;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;)&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;AS&lt;/font&gt;&lt;font size="2"&gt; WeekNumber&lt;/font&gt;&lt;font color="#808080" size="2"&gt;, &lt;/font&gt;&lt;font color="#ff00ff" size="2"&gt;DATEPART&lt;/font&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;font size="2"&gt;isowk&lt;/font&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;&amp;#39;4 jan 2009&amp;#39;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;)&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;AS&lt;/font&gt;&lt;font size="2"&gt; IsoWeekNumber&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p&gt;&lt;font size="2"&gt;Output:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;
&lt;table class="" style="WIDTH:156pt;BORDER-COLLAPSE:collapse;" cellspacing="0" cellpadding="0"&gt;




&lt;tr style="HEIGHT:15pt;"&gt;
&lt;td class="" style="BORDER-RIGHT:#f0f0f0;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;WIDTH:71pt;BORDER-BOTTOM:#f0f0f0;HEIGHT:15pt;BACKGROUND-COLOR:transparent;" height="20"&gt;&lt;font face="Calibri"&gt;WeekNumber&lt;/font&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:#f0f0f0;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;WIDTH:85pt;BORDER-BOTTOM:#f0f0f0;BACKGROUND-COLOR:transparent;"&gt;&lt;font face="Calibri"&gt;IsoWeekNumber&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="HEIGHT:15pt;"&gt;
&lt;td class="xl65" style="BORDER-RIGHT:#f0f0f0;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;BORDER-BOTTOM:#f0f0f0;HEIGHT:15pt;BACKGROUND-COLOR:transparent;" height="20" class="xl65"&gt;&lt;font face="Calibri"&gt;2&lt;/font&gt;&lt;/td&gt;
&lt;td class="xl65" style="BORDER-RIGHT:#f0f0f0;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;BORDER-BOTTOM:#f0f0f0;BACKGROUND-COLOR:transparent;" class="xl65"&gt;&lt;font face="Calibri"&gt;1&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;&lt;/font&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11381" width="1" height="1"&gt;</content><author><name>Repieter</name><uri>http://sqlblogcasts.com/members/Repieter.aspx</uri></author><category term="SQL 2008 IsoWeek" scheme="http://sqlblogcasts.com/blogs/repieter/archive/tags/SQL+2008+IsoWeek/default.aspx" /></entry><entry><title>SSIS "Failure sending mail" problem</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/repieter/archive/2008/10/01/ssis-quot-failure-sending-mail-quot-problem.aspx" /><id>http://sqlblogcasts.com/blogs/repieter/archive/2008/10/01/ssis-quot-failure-sending-mail-quot-problem.aspx</id><published>2008-10-01T11:23:00Z</published><updated>2008-10-01T11:23:00Z</updated><content type="html">&lt;p&gt;I was trying to send an email from an SSIS package when a package failed. However, the Send Mail Task failed everytime. There was no error message except the one in the sysdtslog90 table:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp;An error occurred with the following error message: &amp;quot;Failure sending mail.&amp;quot;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I found the&amp;nbsp;problem was McAfee. Here&amp;#39;s the solution:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Open VirusScan Console&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Double-click &amp;#39;Access Protection&amp;#39;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Uncheck the option &amp;#39;Prevent mass mailing worms from sending mail&amp;#39;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Click Ok&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;After that, McAfee is no longer blocking the outgoing mails.&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=10851" width="1" height="1"&gt;</content><author><name>Repieter</name><uri>http://sqlblogcasts.com/members/Repieter.aspx</uri></author></entry><entry><title>SQL 2005 SSAS deployment error</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/repieter/archive/2008/04/03/sql-2005-ssas-deployment-error.aspx" /><id>http://sqlblogcasts.com/blogs/repieter/archive/2008/04/03/sql-2005-ssas-deployment-error.aspx</id><published>2008-04-03T09:14:00Z</published><updated>2008-04-03T09:14:00Z</updated><content type="html">&lt;p&gt;During a deployment of an SSAS project I got an error saying something about System.Data.Listener. The problem was that the server didn&amp;#39;t have Service Pack 1 of the .Net Framework installed. After that the problem was solved.&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=10288" width="1" height="1"&gt;</content><author><name>Repieter</name><uri>http://sqlblogcasts.com/members/Repieter.aspx</uri></author></entry><entry><title>SSAS2005 - Using logged in user within a role</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/repieter/archive/2007/12/07/ssas2005-using-logged-in-user-within-a-role.aspx" /><id>http://sqlblogcasts.com/blogs/repieter/archive/2007/12/07/ssas2005-using-logged-in-user-within-a-role.aspx</id><published>2007-12-07T11:27:00Z</published><updated>2007-12-07T11:27:00Z</updated><content type="html">&lt;P&gt;A customer of ours has a security model stored in a database and they wanted to have the security in the cube to be the same, so I came up with te following solution:&lt;/P&gt;
&lt;P&gt;Example of the database in which the security is stored:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG style="WIDTH:451px;HEIGHT:258px;" height=258 src="http://www.inderdation.nl/PieterBlog/SecurityModel.jpg" width=451&gt;&lt;/P&gt;
&lt;P&gt;The DimUser table contains the users and their AD login account. The FactHours contains the hours that they have booked. The security is&amp;nbsp;stored in&amp;nbsp;the&amp;nbsp;many-to-many table FactHoursDimUser, so the data in this table shows which user can see which fact. Go to the "Dimension Usage"&amp;nbsp;tab to set the right relationships between the tables:&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:484px;HEIGHT:166px;" height=166 src="http://www.inderdation.nl/PieterBlog/SecurityModel3.jpg" width=484&gt;&lt;/P&gt;
&lt;P&gt;Next step is to add a role to the cube and add user groups on the Membership tab.&lt;/P&gt;
&lt;P&gt;After that, you go to the dimension data tab, select the user dimension, the loginname attribute and then enter the following MDX expression to the "Allowed member set" section: {STRTOMEMBER("[User].[Loginname].[" + username+ "]")}. Also, make sure that "Enable visual totals" is enabled, so the calculations for the&amp;nbsp;totals will only show what&amp;nbsp;the logged in user is allowed to see.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:401px;HEIGHT:156px;" height=156 src="http://www.inderdation.nl/PieterBlog/SecurityModel2.jpg" width=401&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;After that, process the cube and go to the browser tab. Select "Switch user" to view the cube data with other credentials to see the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=5296" width="1" height="1"&gt;</content><author><name>Repieter</name><uri>http://sqlblogcasts.com/members/Repieter.aspx</uri></author></entry><entry><title>SSAS2005 - Processing failed due to collation difference</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/repieter/archive/2007/11/28/ssas2005-processing-failed-due-to-collation-difference.aspx" /><id>http://sqlblogcasts.com/blogs/repieter/archive/2007/11/28/ssas2005-processing-failed-due-to-collation-difference.aspx</id><published>2007-11-28T14:03:00Z</published><updated>2007-11-28T14:03:00Z</updated><content type="html">&lt;P&gt;Today, I was trying to create a simple dimension, but kept getting the error "Attribute&amp;nbsp;key cannot be found". Since I was processing a dimension without any relationship to another table, I was very surprised to see this error. It appeared that there was&amp;nbsp;one record that had a column containing&amp;nbsp;the character 'ë'. When I changed this to the character 'e', everything worked. So, after checking the collation I&amp;nbsp;saw that&amp;nbsp;the relational database was Latin1_General_CP1_CI_AS and&amp;nbsp;the cube&amp;nbsp;was Latin1_General_CP1_CI_AI.&lt;/P&gt;
&lt;P&gt;So, in order to fix this:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Open the management studio&lt;/LI&gt;
&lt;LI&gt;Connect to the Database Engine&lt;/LI&gt;
&lt;LI&gt;Right click the Instance and select properties to see which collation is used&lt;/LI&gt;
&lt;LI&gt;Connect to the&amp;nbsp;Analysis Services&lt;/LI&gt;
&lt;LI&gt;Right-click the Instance and select properties&lt;/LI&gt;
&lt;LI&gt;Click on "Language/Collation"&lt;/LI&gt;
&lt;LI&gt;In my case:&amp;nbsp;check the box&amp;nbsp;"Accent-Sensitive"&lt;/LI&gt;
&lt;LI&gt;Click Ok&lt;/LI&gt;
&lt;LI&gt;Restart the SQL Server service&lt;/LI&gt;
&lt;LI&gt;Restart the Analysis Services service&lt;/LI&gt;
&lt;LI&gt;Re-deploy the Analysis Services database&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;After that it worked. I guess the person who installed the software didn't select the default settings (?)&lt;/P&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=4904" width="1" height="1"&gt;</content><author><name>Repieter</name><uri>http://sqlblogcasts.com/members/Repieter.aspx</uri></author></entry></feed>
