<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sentient beings</title>
	<atom:link href="http://www.sentientbeings.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sentientbeings.com</link>
	<description>Adventures in BI</description>
	<lastBuildDate>Wed, 18 Apr 2012 06:14:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>SSIS: Expression for finding the the first and last day of the month</title>
		<link>http://www.sentientbeings.com/2012/04/ssis-expression-for-finding-the-the-first-and-last-day-of-the-month/</link>
		<comments>http://www.sentientbeings.com/2012/04/ssis-expression-for-finding-the-the-first-and-last-day-of-the-month/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 06:10:19 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Selfish]]></category>

		<guid isPermaLink="false">http://www.sentientbeings.com/?p=175</guid>
		<description><![CDATA[Have you ever needed to adjust dates in SSIS to the first or last day of the month? The following expression will find the first or last day of the month for a given date. These expressions also account for leap years. Adjust a date to the first day of the month. "2005-01-15" will become [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever needed to adjust dates in SSIS to the first or last day of the month? The following expression will find the first or last day of the month for a given date. These expressions also account for leap years.</p>
<p><strong>Adjust a date to the first day of the month.</strong><br />
"2005-01-15" will become "2005-01-01".</p>
<pre>DATEADD("d",DAY(Your_date_here) * -1 + 1,Your_date_here)</pre>
<p><strong>Adjust a date to the last day of the month.</strong><br />
"2005-01-15" will become "2005-01-31".</p>
<pre>DATEADD("d",-1,DATEADD("m",1,DATEADD("d",DAY(Your_date_here) * -1 + 1,Your_date_here)))</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sentientbeings.com/2012/04/ssis-expression-for-finding-the-the-first-and-last-day-of-the-month/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to stop SSIS from converting text to scientific notation when importing from Excel</title>
		<link>http://www.sentientbeings.com/2012/03/how-to-stop-ssis-from-converting-text-to-scientific-notation-when-importing-from-excel/</link>
		<comments>http://www.sentientbeings.com/2012/03/how-to-stop-ssis-from-converting-text-to-scientific-notation-when-importing-from-excel/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 04:54:40 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://www.sentientbeings.com/?p=169</guid>
		<description><![CDATA[For no apparent reason, importing data from Excel sometimes gives you strange scientific notations for columns that are explicitly defined as text, ie, DT_WSTR. Entries like 9000000000 will be converted to 9.00E+09. What happens is that at one point or another, the Excel file has been opened and saved again. It does not matter if [...]]]></description>
			<content:encoded><![CDATA[<p>For no apparent reason, importing data from Excel sometimes gives you strange scientific notations for columns that are explicitly defined as text, ie,  DT_WSTR. Entries like 9000000000 will be converted to 9.00E+09.</p>
<p>What happens is that at one point or another, the Excel file has been opened and saved again. It does not matter if anything has been edited between opening and saving. Upon opening the file, Excel will convert the numbers in any column with mixed data to scientific notation if they become too large or if they don't fit within the column. Once you save the file, the change becomes permanent in a way that Excel replaces the value that was in the cell with the scientific notation. When you import the saved file, you will get the scientific notation. This only happens when there is no explicit format defined for the column, or the column is defined as general.</p>
<p>To avoid this, before saving the Excel sheet, the offending column should be explicitly defined as text within Excel. Doing so will revert the conversions Excel made to your column. If you still see scientific notation, try expanding the width of the column. You can also do this for Excel files that have already been saved. Explicitly mark the column as text and enlarge the column to see the result. When importing the file into SSIS after these operations, life is peachy, again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentientbeings.com/2012/03/how-to-stop-ssis-from-converting-text-to-scientific-notation-when-importing-from-excel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-Sql: How to find the maximum value for a field, or the second largest value, or the third largest value, or &#8230;</title>
		<link>http://www.sentientbeings.com/2012/01/t-sql-how-to-find-the-maximum-value-for-a-field-or-the-second-largest-value-or-the-third-largest-value-or/</link>
		<comments>http://www.sentientbeings.com/2012/01/t-sql-how-to-find-the-maximum-value-for-a-field-or-the-second-largest-value-or-the-third-largest-value-or/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 10:01:01 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Selfish]]></category>
		<category><![CDATA[Sql]]></category>

		<guid isPermaLink="false">http://www.sentientbeings.com/?p=150</guid>
		<description><![CDATA[Many queries you write will be about finding the most recent data for a certain type of event, or the highest value for a certain object. While this is a straightforward query type, it gets complicated and ugly when you have to link two or more tables to find your maximum or minimum value. And [...]]]></description>
			<content:encoded><![CDATA[<p>Many queries you write will be about finding the most recent data for a certain type of event, or the highest value for a certain object. While this is a straightforward query type, it gets complicated and ugly when you have to link two or more tables to find your maximum or minimum value.  And it gets even more complicated when you don’t have to find the maximum value but the value that is just below the maximum value.</p>
<p>In the rest of the article, I will be talking about the maximum value for a field, but it’s also true of course for the minimum value.<br />
The query type you will encounter most often contains a subquery where the current value is compared to the maximum value for that particular field. A simple example is presented below.</p>
<pre class="tsql">&nbsp;
<span style="color: #0000FF;">SELECT</span>
  <span style="color: #FF00FF;">MAX</span><span style="color: #808080;">&#40;</span>tb2.<span style="color: #202020;">Field</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> MaxValueForField
<span style="color: #0000FF;">FROM</span>
  table1 tb1
    <span style="color: #0000FF;">INNER</span> join
  table2 tb2
    <span style="color: #0000FF;">ON</span>  tb2.<span style="color: #202020;">foreign_key</span> = tb1.<span style="color: #202020;">primary_key</span>
<span style="color: #0000FF;">WHERE</span>
  tb2.<span style="color: #202020;">Field</span> = <span style="color: #808080;">&#40;</span>
          <span style="color: #0000FF;">SELECT</span>
            <span style="color: #FF00FF;">MAX</span><span style="color: #808080;">&#40;</span>_tb2.<span style="color: #202020;">field</span><span style="color: #808080;">&#41;</span>
          <span style="color: #0000FF;">FROM</span>
            table1 _tb1
              <span style="color: #0000FF;">INNER</span> join
            table2 _tb2
              <span style="color: #0000FF;">ON</span>  _tb2.<span style="color: #202020;">foreign_key</span> = _tb1.<span style="color: #202020;">primary_key</span>
          <span style="color: #0000FF;">WHERE</span>
            _tb1.<span style="color: #202020;">primary_key</span> = tb1.<span style="color: #202020;">primary_key</span>
        <span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">GROUP</span> <span style="color: #0000FF;">BY</span>
  tb1.<span style="color: #202020;">primary_key</span>
&nbsp;</pre>
<p>The subquery can be avoided with a Common Table Expression that not only speeds up the entire query but also offers a solution for another problem that I will be discussing below.</p>
<pre class="tsql">&nbsp;
;
<span style="color: #0000FF;">WITH</span> tb2Sorted
&nbsp;
<span style="color: #0000FF;">AS</span>
&nbsp;
<span style="color: #808080;">&#40;</span>
  <span style="color: #0000FF;">SELECT</span>
    Row_Number<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">OVER</span> <span style="color: #808080;">&#40;</span>partition <span style="color: #0000FF;">BY</span> tb1.<span style="color: #202020;">primary_key</span> <span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> tb2.<span style="color: #202020;">Field</span> <span style="color: #0000FF;">DESC</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> RowId,
    Field
  <span style="color: #0000FF;">FROM</span>
    table1 tb1
      <span style="color: #0000FF;">INNER</span> join
    table2 tb2
      <span style="color: #0000FF;">ON</span>  tb2.<span style="color: #202020;">foreign_key</span> = tb1.<span style="color: #202020;">primary_key</span>
<span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">SELECT</span>
  Field <span style="color: #0000FF;">AS</span> MaximaleIngangsDatum
<span style="color: #0000FF;">FROM</span>
  tb2Sorted
<span style="color: #0000FF;">WHERE</span>
  RowId = <span style="color: #000;">1</span>
&nbsp;</pre>
<p>This query performs better than the first one but also offers another advantage. </p>
<p>You can easily find the second or third largest value by simple changing the RowId. Bear in mind that this will not remove duplicates. If the values for Field are 1,1,2,5,5 then RowId 1 will yield 5 and RowId 2 will also yield 5. You can find the top 5 largest values for a certain field by simply changing the where clause to read RowId < 6.</p>
<pre class="tsql">&nbsp;
;
<span style="color: #0000FF;">WITH</span> tb2Sorted
&nbsp;
<span style="color: #0000FF;">AS</span>
&nbsp;
<span style="color: #808080;">&#40;</span>
  <span style="color: #0000FF;">SELECT</span>
    Row_Number<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">OVER</span> <span style="color: #808080;">&#40;</span>partition <span style="color: #0000FF;">BY</span> tb1.<span style="color: #202020;">primary_key</span> <span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> tb2.<span style="color: #202020;">Field</span> <span style="color: #0000FF;">DESC</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> RowId,
    Field,
    RowId
  <span style="color: #0000FF;">FROM</span>
    table1 tb1
      <span style="color: #0000FF;">INNER</span> join
    table2 tb2
      <span style="color: #0000FF;">ON</span>  tb2.<span style="color: #202020;">foreign_key</span> = tb1.<span style="color: #202020;">primary_key</span>
<span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">SELECT</span>
  Field <span style="color: #0000FF;">AS</span> MaximaleIngangsDatum
<span style="color: #0000FF;">FROM</span>
  tb2Sorted
<span style="color: #0000FF;">WHERE</span>
  RowId &lt; <span style="color: #000;">6</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sentientbeings.com/2012/01/t-sql-how-to-find-the-maximum-value-for-a-field-or-the-second-largest-value-or-the-third-largest-value-or/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-SQL: Find any string in any column in any table in a database.</title>
		<link>http://www.sentientbeings.com/2012/01/t-sql-find-any-string-in-any-column-in-any-table-in-a-database/</link>
		<comments>http://www.sentientbeings.com/2012/01/t-sql-find-any-string-in-any-column-in-any-table-in-a-database/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 08:16:43 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Sql]]></category>

		<guid isPermaLink="false">http://www.sentientbeings.com/?p=142</guid>
		<description><![CDATA[Have you ever found yourself in need of finding a certain string in an entire database? As a freelance BI consultant, this happens to me rather frequently when analysing where and how data is stored and how to retrieve it. So I came up with this code. It lets you find a string in any [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever found yourself in need of finding a certain string in an entire database? As a freelance BI consultant, this happens to me rather frequently when analysing where and how data is stored and how to retrieve it.</p>
<p>So I came up with this code. It lets you find a string in any column in any table on your database. It's a pretty length search if you have a lot of data and a lot of columns and tables, but it sure beats searching by hand.</p>
<p>Be warned! This may run a pretty long time on large databases.</p>
<pre class="tsql">&nbsp;
<span style="color: #0000FF;">DECLARE</span> @searchString <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">MAX</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">DECLARE</span> @sqlString <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">MAX</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">DECLARE</span> @processedString <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">MAX</span><span style="color: #808080;">&#41;</span>
&nbsp;
<span style="color: #008080;">-- Insert your searchstring below</span>
<span style="color: #008080;">-- Use \ as escape character</span>
<span style="color: #008080;">-- examples:</span>
<span style="color: #008080;">--	to search for 'I'm waiting', use 'I\'m waiting'</span>
<span style="color: #008080;">--	to search for '25%' use '25\%'</span>
&nbsp;
<span style="color: #0000FF;">SELECT</span>
	@searchString = <span style="color: #FF0000;">'naar achter'</span>
&nbsp;
<span style="color: #0000FF;">DECLARE</span> @resultTable	<span style="color: #0000FF;">TABLE</span>
<span style="color: #808080;">&#40;</span>
	table_name	<span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">255</span><span style="color: #808080;">&#41;</span>,
	<span style="color: #FF00FF;">COL_NAME</span>	<span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">255</span><span style="color: #808080;">&#41;</span>,
	value_found	<span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">MAX</span><span style="color: #808080;">&#41;</span>,
	<span style="color: #FF00FF;">OBJECT_ID</span>	<span style="color: #0000FF;">INT</span>,
	col_id	<span style="color: #0000FF;">INT</span>
<span style="color: #808080;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">SELECT</span>
	@sqlString = <span style="color: #FF0000;">'-- start'</span>,
	@processedString = <span style="color: #FF0000;">''</span>
&nbsp;
<span style="color: #0000FF;">WHILE</span>
	@sqlString &gt; <span style="color: #FF0000;">''</span>
<span style="color: #0000FF;">BEGIN</span>
&nbsp;
	<span style="color: #0000FF;">SELECT</span>
		@sqlString = <span style="color: #FF0000;">''</span>,
		@processedString = <span style="color: #FF0000;">''</span>
&nbsp;
	<span style="color: #0000FF;">SELECT</span>
		@processedString = @processedString +
		<span style="color: #0000FF;">CASE</span>
			<span style="color: #0000FF;">WHEN</span> DATALENGTH<span style="color: #808080;">&#40;</span>@sqlString<span style="color: #808080;">&#41;</span> &lt; <span style="color: #000;">7500</span> <span style="color: #008080;">-- assume a sql statement will never go beyond 500 characters</span>
			<span style="color: #0000FF;">THEN</span>
		<span style="color: #FF0000;">'
			select
				'</span><span style="color: #FF0000;">''</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>SCHEMA_NAME<span style="color: #808080;">&#40;</span>tbl.<span style="color: #202020;">schema_id</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">'.'</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">OBJECT_NAME</span><span style="color: #808080;">&#40;</span>tbl.<span style="color: #FF00FF;">OBJECT_ID</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">''</span><span style="color: #FF0000;">' as table_name,
				'</span><span style="color: #FF0000;">''</span> + col.<span style="color: #202020;">name</span> + <span style="color: #FF0000;">''</span><span style="color: #FF0000;">',
				NULL as value_found,
				'</span> + <span style="color: #0000FF;">CONVERT</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">NVARCHAR</span>,tbl.<span style="color: #FF00FF;">OBJECT_ID</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">' as object_id,
				'</span> + <span style="color: #0000FF;">CONVERT</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">NVARCHAR</span>,col.<span style="color: #202020;">column_id</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">' as col_id
		'</span>
			<span style="color: #0000FF;">ELSE</span>
				<span style="color: #FF0000;">''</span>
		<span style="color: #0000FF;">END</span>,
		@sqlString = @sqlString +
		<span style="color: #0000FF;">CASE</span>
			<span style="color: #0000FF;">WHEN</span> DATALENGTH<span style="color: #808080;">&#40;</span>@sqlString<span style="color: #808080;">&#41;</span> &lt; <span style="color: #000;">7500</span> <span style="color: #008080;">-- assume a sql statement will never go beyond 500 characters</span>
			<span style="color: #0000FF;">THEN</span>
		<span style="color: #FF0000;">'
			select
				top 1
				'</span><span style="color: #FF0000;">''</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>SCHEMA_NAME<span style="color: #808080;">&#40;</span>tbl.<span style="color: #202020;">schema_id</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">'.'</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">OBJECT_NAME</span><span style="color: #808080;">&#40;</span>tbl.<span style="color: #FF00FF;">OBJECT_ID</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">''</span><span style="color: #FF0000;">' as table_name,
				'</span><span style="color: #FF0000;">''</span> + col.<span style="color: #202020;">name</span> + <span style="color: #FF0000;">''</span><span style="color: #FF0000;">',
				'</span> + col.<span style="color: #202020;">name</span> + <span style="color: #FF0000;">' as value_found,
				'</span> + <span style="color: #0000FF;">CONVERT</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">NVARCHAR</span>,tbl.<span style="color: #FF00FF;">OBJECT_ID</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">' as object_id,
				'</span> + <span style="color: #0000FF;">CONVERT</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">NVARCHAR</span>,col.<span style="color: #202020;">column_id</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">' as col_id
			from
				'</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>SCHEMA_NAME<span style="color: #808080;">&#40;</span>tbl.<span style="color: #202020;">schema_id</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">'.'</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">OBJECT_NAME</span><span style="color: #808080;">&#40;</span>tbl.<span style="color: #FF00FF;">OBJECT_ID</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">'
			where
				'</span> + col.<span style="color: #202020;">name</span> + <span style="color: #FF0000;">' like '</span><span style="color: #FF0000;">'%'</span> + @searchString + <span style="color: #FF0000;">'%'</span><span style="color: #FF0000;">' escape '</span><span style="color: #FF0000;">'<span style="color: #000099; font-weight: bold;">\'</span>'</span>
		<span style="color: #FF0000;">'
			else
				'</span><span style="color: #FF0000;">'
		end
	from
		sys.columns col
			inner join
		sys.tables tbl
			on	col.object_id = tbl.object_id
			and	col.user_type_id in (231, 167, 175, 239)
			 --	nvarchar, varchar, char, nchar
			 --	no text
			left join
		@resultTable rst
			on	col.column_id = rst.col_id
			and	col.object_id = rst.object_id
	where
		rst.table_name is null
&nbsp;
	print	@sqlString
	print	@processedString	
&nbsp;
	insert into
		@resultTable
	exec
		(@sqlString)
&nbsp;
	insert into
		@resultTable
	exec
		(@processedString)
&nbsp;
	print	'</span><span style="color: #008080;">---8&lt;-----------------------------------------------------------------------------------------------'</span>
&nbsp;
<span style="color: #0000FF;">END</span>
&nbsp;
<span style="color: #0000FF;">SELECT</span>
	table_name,
	<span style="color: #FF00FF;">COL_NAME</span>,
	value_found
<span style="color: #0000FF;">FROM</span>
	@resultTable
<span style="color: #0000FF;">WHERE</span>
	value_found <span style="color: #0000FF;">IS</span> not null
<span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span>
	<span style="color: #000;">1</span>, <span style="color: #000;">2</span>, <span style="color: #000;">3</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sentientbeings.com/2012/01/t-sql-find-any-string-in-any-column-in-any-table-in-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drop all foreign keys on a database and optionally drop all tables</title>
		<link>http://www.sentientbeings.com/2012/01/drop-all-foreign-keys-on-a-database-and-optionally-drop-all-tables/</link>
		<comments>http://www.sentientbeings.com/2012/01/drop-all-foreign-keys-on-a-database-and-optionally-drop-all-tables/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 08:48:02 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Sql]]></category>

		<guid isPermaLink="false">http://www.sentientbeings.com/?p=135</guid>
		<description><![CDATA[If you've ever found the need to drop or remove all foreign keys on a database then here's a little script that runs without cursors. &#160; DECLARE @SQL NVARCHAR&#40;MAX&#41; &#160; SELECT @SQL = '-- Start ' &#160; WHILE @SQL &#62; '' BEGIN SELECT @SQL = '' &#160; SELECT @SQL = @SQL + CASE WHEN DATALENGTH&#40;@SQL&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>If you've ever found the need to drop or remove all foreign keys on a database then here's a little script that runs without cursors. </p>
<pre class="tsql">&nbsp;
<span style="color: #0000FF;">DECLARE</span> @<span style="color: #0000FF;">SQL</span> <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">MAX</span><span style="color: #808080;">&#41;</span>	
&nbsp;
<span style="color: #0000FF;">SELECT</span>
	@<span style="color: #0000FF;">SQL</span> = <span style="color: #FF0000;">'-- Start '</span>
&nbsp;
<span style="color: #0000FF;">WHILE</span> @<span style="color: #0000FF;">SQL</span> &gt; <span style="color: #FF0000;">''</span>
<span style="color: #0000FF;">BEGIN</span>
	<span style="color: #0000FF;">SELECT</span>
		@<span style="color: #0000FF;">SQL</span> = <span style="color: #FF0000;">''</span>
&nbsp;
	<span style="color: #0000FF;">SELECT</span>
		@<span style="color: #0000FF;">SQL</span> = @<span style="color: #0000FF;">SQL</span> +
			<span style="color: #0000FF;">CASE</span>
				<span style="color: #0000FF;">WHEN</span> DATALENGTH<span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">SQL</span><span style="color: #808080;">&#41;</span> &lt; <span style="color: #000;">7500</span> <span style="color: #0000FF;">THEN</span>
					N<span style="color: #FF0000;">'alter table '</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>schema_name<span style="color: #808080;">&#40;</span>schema_id<span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
					+ N<span style="color: #FF0000;">'.'</span>
					+ <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">OBJECT_NAME</span><span style="color: #808080;">&#40;</span>parent_object_id<span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
					+ N<span style="color: #FF0000;">' drop constraint '</span>
					+ name
					+ <span style="color: #0000FF;">CHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">13</span><span style="color: #808080;">&#41;</span> + <span style="color: #0000FF;">CHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">10</span><span style="color: #808080;">&#41;</span> <span style="color: #008080;">--+ 'GO' + CHAR(13) + CHAR(10)</span>
				<span style="color: #0000FF;">ELSE</span>
					<span style="color: #FF0000;">''</span>
			<span style="color: #0000FF;">END</span>
	<span style="color: #0000FF;">FROM</span>
		sys.<span style="color: #202020;">foreign_keys</span>
&nbsp;
	<span style="color: #0000FF;">PRINT</span> @<span style="color: #0000FF;">SQL</span>
	<span style="color: #0000FF;">EXEC</span> <span style="color: #AF0000;">SP_EXECUTESQL</span> @<span style="color: #0000FF;">SQL</span>
	<span style="color: #0000FF;">PRINT</span> <span style="color: #FF0000;">'---8&lt;------------------------------------------------------------------------------------------'</span>
<span style="color: #0000FF;">END</span>
&nbsp;
GO
&nbsp;
<span style="color: #008080;">---8&lt;-------------------------------------------------------------</span>
<span style="color: #008080;">-- Uncomment the line below to drop all tables too</span>
&nbsp;
<span style="color: #008080;">--exec sp_msforeachtable 'drop table ?'</span>
&nbsp;
<span style="color: #0000FF;">PRINT</span> <span style="color: #FF0000;">'All done'</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sentientbeings.com/2012/01/drop-all-foreign-keys-on-a-database-and-optionally-drop-all-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-SQL List all columns in all tables</title>
		<link>http://www.sentientbeings.com/2012/01/t-sql-list-all-columns-in-all-tables/</link>
		<comments>http://www.sentientbeings.com/2012/01/t-sql-list-all-columns-in-all-tables/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 08:40:01 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Sql]]></category>

		<guid isPermaLink="false">http://www.sentientbeings.com/?p=132</guid>
		<description><![CDATA[If you've ever wanted to get a listing of all the columns in all of the tables in a certain database, here's how. I use this often for writing technical documentation on systems. This little code will list all of your tables, columns, datatypes, nullable option, identity option and will also indicate primary and foreign [...]]]></description>
			<content:encoded><![CDATA[<p>If you've ever wanted to get a listing of all the columns in all of the tables in a certain database, here's how. I use this often for writing technical documentation on systems.</p>
<p>This little code will list all of your tables, columns, datatypes, nullable option, identity option and will also indicate primary and foreign keys and default constraints.</p>
<pre class="tsql">&nbsp;
<span style="color: #0000FF;">SELECT</span>
<span style="color: #008080;">--	distinct</span>
<span style="color: #008080;">--	quotename(schema_name(tbl.schema_id)) + N'.' + quotename(tbl.name) as TableName,</span>
<span style="color: #008080;">--	col.column_id,</span>
	col.<span style="color: #202020;">name</span> <span style="color: #0000FF;">AS</span> ColumnName,
	type_name<span style="color: #808080;">&#40;</span>col.<span style="color: #202020;">user_type_id</span><span style="color: #808080;">&#41;</span>+
	<span style="color: #0000FF;">CASE</span>
		<span style="color: #0000FF;">WHEN</span> <span style="color: #FF00FF;">COLUMNPROPERTY</span><span style="color: #808080;">&#40;</span>tbl.<span style="color: #FF00FF;">OBJECT_ID</span>, col.<span style="color: #202020;">name</span>, <span style="color: #FF0000;">'scale'</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">IS</span> null <span style="color: #0000FF;">THEN</span>
			<span style="color: #FF0000;">' ('</span> + <span style="color: #0000FF;">CONVERT</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">VARCHAR</span>,<span style="color: #FF00FF;">COLUMNPROPERTY</span><span style="color: #808080;">&#40;</span>tbl.<span style="color: #FF00FF;">OBJECT_ID</span>, col.<span style="color: #202020;">name</span>, <span style="color: #FF0000;">'precision'</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">')'</span> <span style="color: #008080;">--is null --convert(varchar, col.max_length)</span>
		<span style="color: #0000FF;">WHEN</span> col.<span style="color: #202020;">user_type_id</span> in <span style="color: #808080;">&#40;</span><span style="color: #000;">60</span>, <span style="color: #000;">106</span>, <span style="color: #000;">108</span>, <span style="color: #000;">122</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">THEN</span>
			<span style="color: #FF0000;">' ('</span> + <span style="color: #0000FF;">CONVERT</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">VARCHAR</span>,col.<span style="color: #0000FF;">PRECISION</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">','</span> + <span style="color: #0000FF;">CONVERT</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">VARCHAR</span>, col.<span style="color: #202020;">scale</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">')'</span>
		<span style="color: #0000FF;">ELSE</span> <span style="color: #FF0000;">''</span>
	<span style="color: #0000FF;">END</span>	<span style="color: #0000FF;">AS</span> DataType,
	<span style="color: #0000FF;">CASE</span> col.<span style="color: #202020;">is_nullable</span>
		<span style="color: #0000FF;">WHEN</span> <span style="color: #000;">0</span> <span style="color: #0000FF;">THEN</span> <span style="color: #FF0000;">'NOT '</span>
		<span style="color: #0000FF;">ELSE</span> <span style="color: #FF0000;">''</span>
	<span style="color: #0000FF;">END</span>
		+	 <span style="color: #FF0000;">'NULL'</span> <span style="color: #0000FF;">AS</span> Nullable,
	<span style="color: #0000FF;">CASE</span> col.<span style="color: #202020;">is_identity</span>
		<span style="color: #0000FF;">WHEN</span> <span style="color: #000;">0</span> <span style="color: #0000FF;">THEN</span> <span style="color: #FF0000;">''</span>
		<span style="color: #0000FF;">ELSE</span> <span style="color: #FF0000;">'IDENTITY ('</span> + <span style="color: #0000FF;">CONVERT</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">VARCHAR</span>, idc.<span style="color: #202020;">seed_value</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">','</span> + <span style="color: #0000FF;">CONVERT</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">VARCHAR</span>, idc.<span style="color: #202020;">increment_value</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">')'</span>
	<span style="color: #0000FF;">END</span>	<span style="color: #0000FF;">AS</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">IDENTITY</span><span style="color: #808080;">&#93;</span>,
	<span style="color: #0000FF;">CASE</span>
		<span style="color: #0000FF;">WHEN</span> ixc.<span style="color: #202020;">column_id</span> <span style="color: #0000FF;">IS</span> not null <span style="color: #0000FF;">THEN</span>
			<span style="color: #FF0000;">'PK'</span>
		<span style="color: #0000FF;">WHEN</span> fkc.<span style="color: #202020;">constraint_object_id</span> <span style="color: #0000FF;">IS</span> not null <span style="color: #0000FF;">THEN</span>
			<span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>schema_name<span style="color: #808080;">&#40;</span>tb2.<span style="color: #202020;">schema_id</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + N<span style="color: #FF0000;">'.'</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>tb2.<span style="color: #202020;">name</span><span style="color: #808080;">&#41;</span> + N<span style="color: #FF0000;">'.'</span> + fcl.<span style="color: #202020;">name</span>
		<span style="color: #0000FF;">ELSE</span> <span style="color: #FF0000;">''</span>
	<span style="color: #0000FF;">END</span> <span style="color: #0000FF;">AS</span> Key_Constraint,
	<span style="color: #0000FF;">CASE</span>
		<span style="color: #0000FF;">WHEN</span> dfc.<span style="color: #FF00FF;">OBJECT_ID</span> <span style="color: #0000FF;">IS</span> not null <span style="color: #0000FF;">THEN</span>
			dfc.<span style="color: #202020;">definition</span>
		<span style="color: #0000FF;">ELSE</span> <span style="color: #FF0000;">''</span>
	<span style="color: #0000FF;">END</span> <span style="color: #0000FF;">AS</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">DEFAULT</span> <span style="color: #0000FF;">CONSTRAINT</span><span style="color: #808080;">&#93;</span>
<span style="color: #0000FF;">FROM</span>
	sys.<span style="color: #202020;">tables</span> tbl
		<span style="color: #0000FF;">INNER</span> join
	<span style="color: #808080;">&#40;</span>
		<span style="color: #0000FF;">SELECT</span>
			<span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>schema_name<span style="color: #808080;">&#40;</span>tbl.<span style="color: #202020;">schema_id</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + N<span style="color: #FF0000;">'.'</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>tbl.<span style="color: #202020;">name</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> TableName,
			col.<span style="color: #202020;">name</span>,
			col.<span style="color: #202020;">column_id</span>,
			col.<span style="color: #FF00FF;">OBJECT_ID</span>,
			col.<span style="color: #202020;">is_identity</span>,
			col.<span style="color: #202020;">is_nullable</span>,
			col.<span style="color: #0000FF;">PRECISION</span>,
			col.<span style="color: #202020;">scale</span>,
			col.<span style="color: #202020;">user_type_id</span>,
			<span style="color: #000;">1</span> <span style="color: #0000FF;">AS</span> SortKey
		<span style="color: #0000FF;">FROM</span>
			sys.<span style="color: #202020;">columns</span> col
				<span style="color: #0000FF;">INNER</span> join
			sys.<span style="color: #202020;">tables</span> tbl
				<span style="color: #0000FF;">ON</span>	tbl.<span style="color: #FF00FF;">OBJECT_ID</span> = col.<span style="color: #FF00FF;">OBJECT_ID</span>
&nbsp;
		<span style="color: #0000FF;">UNION</span> 
&nbsp;
		<span style="color: #0000FF;">SELECT</span>
			<span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>schema_name<span style="color: #808080;">&#40;</span>tbl.<span style="color: #202020;">schema_id</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + N<span style="color: #FF0000;">'.'</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>tbl.<span style="color: #202020;">name</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> TableName,
			<span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>schema_name<span style="color: #808080;">&#40;</span>tbl.<span style="color: #202020;">schema_id</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + N<span style="color: #FF0000;">'.'</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>tbl.<span style="color: #202020;">name</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> TableName,
			<span style="color: #000;">0</span>,
			tbl.<span style="color: #FF00FF;">OBJECT_ID</span>,
			<span style="color: #000;">0</span>,
			<span style="color: #000;">0</span>,
			<span style="color: #000;">0</span>,
			<span style="color: #000;">0</span>,
			<span style="color: #000;">0</span>,
			<span style="color: #000;">0</span>
		<span style="color: #0000FF;">FROM</span>
			sys.<span style="color: #202020;">tables</span> tbl
&nbsp;
	<span style="color: #808080;">&#41;</span>	col
		<span style="color: #0000FF;">ON</span>	tbl.<span style="color: #FF00FF;">OBJECT_ID</span> = col.<span style="color: #FF00FF;">OBJECT_ID</span>
		<span style="color: #0000FF;">LEFT</span> join
	sys.<span style="color: #202020;">key_constraints</span> pkc
		<span style="color: #0000FF;">ON</span>	pkc.<span style="color: #202020;">parent_object_id</span> = tbl.<span style="color: #FF00FF;">OBJECT_ID</span>
		and	pkc.<span style="color: #202020;">type</span> = <span style="color: #FF0000;">'PK'</span>
		<span style="color: #0000FF;">LEFT</span> join
	sys.<span style="color: #202020;">index_columns</span> ixc
		<span style="color: #0000FF;">ON</span>	ixc.<span style="color: #FF00FF;">OBJECT_ID</span> = tbl.<span style="color: #FF00FF;">OBJECT_ID</span>
		and	ixc.<span style="color: #202020;">index_id</span> = pkc.<span style="color: #202020;">unique_index_id</span>
		and	ixc.<span style="color: #202020;">column_id</span> = col.<span style="color: #202020;">column_id</span>
		<span style="color: #0000FF;">LEFT</span> join
	sys.<span style="color: #202020;">foreign_key_columns</span> fkc
		<span style="color: #0000FF;">ON</span>	fkc.<span style="color: #202020;">parent_object_id</span> = tbl.<span style="color: #FF00FF;">OBJECT_ID</span>
		and	fkc.<span style="color: #202020;">parent_column_id</span> = col.<span style="color: #202020;">column_id</span>
		<span style="color: #0000FF;">LEFT</span> join
	sys.<span style="color: #202020;">columns</span> fcl
		<span style="color: #0000FF;">ON</span>	fkc.<span style="color: #202020;">referenced_column_id</span> = fcl.<span style="color: #202020;">column_id</span>
		and	fkc.<span style="color: #202020;">referenced_object_id</span> = fcl.<span style="color: #FF00FF;">OBJECT_ID</span>
		<span style="color: #0000FF;">LEFT</span> join
	sys.<span style="color: #202020;">tables</span> tb2
		<span style="color: #0000FF;">ON</span>	fcl.<span style="color: #FF00FF;">OBJECT_ID</span> = tb2.<span style="color: #FF00FF;">OBJECT_ID</span>
		<span style="color: #0000FF;">LEFT</span> join
	sys.<span style="color: #202020;">default_constraints</span> dfc
		<span style="color: #0000FF;">ON</span>	dfc.<span style="color: #202020;">parent_object_id</span> = tbl.<span style="color: #FF00FF;">OBJECT_ID</span>
		and	dfc.<span style="color: #202020;">parent_column_id</span> = col.<span style="color: #202020;">column_id</span>
		<span style="color: #0000FF;">LEFT</span> join
	sys.<span style="color: #202020;">identity_columns</span> idc
		<span style="color: #0000FF;">ON</span>	idc.<span style="color: #FF00FF;">OBJECT_ID</span> = tbl.<span style="color: #FF00FF;">OBJECT_ID</span>
		and	idc.<span style="color: #202020;">column_id</span> = col.<span style="color: #202020;">column_id</span>
<span style="color: #0000FF;">WHERE</span>
	tbl.<span style="color: #202020;">type</span> = <span style="color: #FF0000;">'U'</span>
<span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span>
	<span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>schema_name<span style="color: #808080;">&#40;</span>tbl.<span style="color: #202020;">schema_id</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> + N<span style="color: #FF0000;">'.'</span> + <span style="color: #FF00FF;">QUOTENAME</span><span style="color: #808080;">&#40;</span>tbl.<span style="color: #202020;">name</span><span style="color: #808080;">&#41;</span>,
	SortKey,
	ColumnName
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sentientbeings.com/2012/01/t-sql-list-all-columns-in-all-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LaCie Internet Space no longer works.</title>
		<link>http://www.sentientbeings.com/2011/11/lacie-internet-space-no-longer-works/</link>
		<comments>http://www.sentientbeings.com/2011/11/lacie-internet-space-no-longer-works/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 12:34:29 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Selfish]]></category>

		<guid isPermaLink="false">http://www.sentientbeings.com/?p=128</guid>
		<description><![CDATA[A few weeks ago, I noticed that my Lacie Internet Space was offline. Not a real problem, since the LaCie Internet Space will go offline every once in a while. A powercycle is usually enough to get it going again. But to my dismay, not this time. I powercycled the LaCie Internet Space and it [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, I noticed that my Lacie Internet Space was offline. Not a real problem, since the LaCie Internet Space will go offline every once in a while. A powercycle is usually enough to get it going again.</p>
<p>But to my dismay, not this time. I powercycled the LaCie Internet Space and it booted allright, the blue light came on and then ... nothing.</p>
<p>I dismantled the complete thing, took out the drive (Hitachi Deskstar 1TB 7200 RPM) and plugged it into my usb/sata converter and again, nothing happened.</p>
<p>Cue slight panic as my entire music collection was stored on this, as well as my wife's photo portfolio. Since the drive did seem to spin up, I suspected the logic board. I scoured the internet for an exact hard disk and found one. In the meantime, I had also bought a second hand LaCie Internet Space, thinking there would be a Hitachi Deskstar inside but it turned out to be a Samsung HD103SI. I discarded the second LaCie Internet Space and put all my hopes on the spare disc, which, by the way, was rather expensive due to the floods in Thailand.</p>
<p>I switched the logic boards, connected the Hitachi to the usb/sata converter and nothing happened. I replaced the logic boards and in a final act of lucidity decided to put the hard drive into the replacement LaCie Internet Space casing. All of a sudden, the disc sprang back to live, started rattling merrily and I could see the disc once again in my network places.</p>
<p>It seemed that the hard disc wasn't at fault but the original LaCie Internet Sace casing. Go figure. Why the drive wasn't recognised by the usb/sata converter is beyond me. I'm copying 1 TB of data to my other NAS right now and I'm never buying anything from LaCie again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentientbeings.com/2011/11/lacie-internet-space-no-longer-works/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to solve &#8220;Internal error: Invalid enumeration value. Please call customer support! is not a valid value for this element.&#8221;</title>
		<link>http://www.sentientbeings.com/2011/11/how-to-solve-internal-error-invalid-enumeration-value-please-call-customer-support-is-not-a-valid-value-for-this-element/</link>
		<comments>http://www.sentientbeings.com/2011/11/how-to-solve-internal-error-invalid-enumeration-value-please-call-customer-support-is-not-a-valid-value-for-this-element/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 12:55:21 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Sql]]></category>

		<guid isPermaLink="false">http://www.sentientbeings.com/?p=129</guid>
		<description><![CDATA[When deploying a cube to SSAS (Sql Server Analysis Services) 10.50 aka 2008r2 using Visual Studio 2008, I got the following errors. Internal error: Invalid enumeration value. Please call customer support! is not a valid value for this element. An error occurred while parsing the 'StorageMode' element at line 1, column 6751 ('http://schemas.microsoft.com/analysisservices/2003/engine' namespace) under [...]]]></description>
			<content:encoded><![CDATA[<p>When deploying a cube to SSAS (Sql Server Analysis Services) 10.50 aka 2008r2 using Visual Studio 2008, I got the following errors.</p>
<ol>
<li>Internal error: Invalid enumeration value. Please call customer support! is not a valid value for this element.</li>
<li>An error occurred while parsing the 'StorageMode' element at line 1, column 6751 ('http://schemas.microsoft.com/analysisservices/2003/engine' namespace) under Load/ObjectDefinition/Dimension/StorageMode.
</li>
<li>Errors in the metadata manager. An error occurred when instantiating a metadata object from the file, '\\?\N:\SSAS\OLAP\Data\RMT_CUBE\RP DIM TIME.12.dim.xml'</li>
</ol>
<p>Additionally, building the project and then deploying using the wizard results in a similar string of error messages</p>
<p>The column in the second error and the file referenced in the third error may vary. The filename in the third error however is worth noticing because it's the dimension that is stopping you from deploying. In this case, my dimension was named "RMT DIM TIME".</p>
<p>On the internet, you will find many solutions advising you to drop the database and redeploy. I have found a way that is less time consuming and a lot less worrying than simply dropping your entire database.</p>
<p>I was able to solve the problem by simply re-processing the offending dimension in SSMS (Sql Server Management Studio). After re-processing the offending dimension, life was peachy again.</p>
<p>Hope this helps you. Apparently, installing the latest SSAS service pack would also solve the problem but that's not always a straightforward solution in a managed environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentientbeings.com/2011/11/how-to-solve-internal-error-invalid-enumeration-value-please-call-customer-support-is-not-a-valid-value-for-this-element/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows XP Raw Support for CR2</title>
		<link>http://www.sentientbeings.com/2010/06/windows-xp-raw-support-for-cr2/</link>
		<comments>http://www.sentientbeings.com/2010/06/windows-xp-raw-support-for-cr2/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 08:21:31 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://www.sentientbeings.com/?p=125</guid>
		<description><![CDATA[I thought I had tried about everything to get CR2 RAW support up and running in Windows XP. I installed the Canon Codec and tried to open the files with the regular Windows Fax and Picture viewer. FAIL! I installed Microsoft's Powertoy "Microsoft RAW Image Thumbnailer and Viewer for Windows XP" but that failed with [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I had tried about everything to get CR2 RAW support up and running in Windows XP. I installed the Canon Codec and tried to open the files with the regular Windows Fax and Picture viewer. FAIL!</p>
<p>I installed Microsoft's Powertoy "Microsoft RAW Image Thumbnailer and Viewer for Windows XP" but that failed with a "cannot load image" message. I was at wit's end. Until ...</p>
<p>Finally, I discovered that Microsoft's Live Photo Gallery that is part of Vista and Windows 7 and that does suppot CR2 RAW files was available for Windows XP. Download it here: <a href="http://download.live.com/photogallery">http://download.live.com/photogallery</a> and then uncheck all the vile software you don't need. Et voila, CR2 RAW support from your explorer in Windows XP.</p>
<p>Whew. That only took me about 2 hours to fix.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentientbeings.com/2010/06/windows-xp-raw-support-for-cr2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to solve Event ID 17120: SQL Server could spawn not lazy writer thread</title>
		<link>http://www.sentientbeings.com/2010/06/how-to-solve-event-id-17120-sql-server-could-spawn-not-lazy-writer-thread/</link>
		<comments>http://www.sentientbeings.com/2010/06/how-to-solve-event-id-17120-sql-server-could-spawn-not-lazy-writer-thread/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 11:06:36 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Selfish]]></category>

		<guid isPermaLink="false">http://www.sentientbeings.com/?p=123</guid>
		<description><![CDATA[After a reboot of my development machine, the SQL Server 2008 R2 service wouldn't start. I consulted the Event viewer, but that only yielded the following message. Log Name: Application Source: MSSQL$SE2008R2 Date: 1-6-2010 12:38:43 Event ID: 17120 Task Category: Server Level: Error Keywords: Classic User: N/A Computer: [censored] Description: SQL Server could not spawn [...]]]></description>
			<content:encoded><![CDATA[<p>After a reboot of my development machine, the SQL Server 2008 R2 service wouldn't start.</p>
<p>I consulted the Event viewer, but that only yielded the following message.</p>
<blockquote><p>Log Name:      Application<br />
Source:        MSSQL$SE2008R2<br />
Date:          1-6-2010 12:38:43<br />
Event ID:      17120<br />
Task Category: Server<br />
Level:         Error<br />
Keywords:      Classic<br />
User:          N/A<br />
Computer:      [censored]<br />
Description:<br />
SQL Server could not spawn lazy writer thread. Check the SQL Server error log and the Windows event logs for information about possible related problems.</p>
<p>Event Xml:<br />
&lt;Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"&gt;<br />
&lt;System&gt;<br />
&lt;Provider Name="MSSQL$SE2008R2" /&gt;<br />
&lt;EventID Qualifiers="49152"&gt;17120&lt;/EventID&gt;<br />
&lt;Level&gt;2&lt;/Level&gt;<br />
&lt;Task&gt;2&lt;/Task&gt;<br />
&lt;Keywords&gt;0x80000000000000&lt;/Keywords&gt;<br />
&lt;TimeCreated SystemTime="2010-06-01T10:38:43.000Z" /&gt;<br />
&lt;EventRecordID&gt;7660&lt;/EventRecordID&gt;<br />
&lt;Channel&gt;Application&lt;/Channel&gt;<br />
&lt;Computer&gt;censored&lt;/Computer&gt;<br />
&lt;Security /&gt;<br />
&lt;/System&gt;<br />
&lt;EventData&gt;<br />
&lt;Data&gt;lazy writer&lt;/Data&gt;<br />
&lt;Binary&gt;E042000010000000130000004400540041003000300035003400360030005C0053004500320030003000380052003200000000000000&lt;/Binary&gt;<br />
&lt;/EventData&gt;<br />
&lt;/Event&gt;</p></blockquote>
<p>After checking the internet for a solution, I came up with none. I decided to check the SQL Server Log file and it contained the following line.</p>
<blockquote><p>I/O affinity turned on, processor mask 0x00000002. Disk I/Os will execute on CPUs per affinity I/O mask/affinity64 mask config option. This is an informational message only; no user action is required.</p></blockquote>
<p>I them remembered that I had tried to assign CPU2 to handle I/O requests. Since the only way to remedy something that goes wrong and which you haven't got a clue about is to retrace your steps, my next step would be to undo that setting. But the SQL Service wouldn't start and the -I command line option didn't work.</p>
<p>I started SQL Server manually as described in this MSDN article: <a href="http://msdn.microsoft.com/en-us/library/ms180965.aspx">How to: Start an Instance of SQL Server (sqlservr.exe)</a>. I specifically used the -f option to make sure SQL Server would start with as little configuration as possible.</p>
<p>SQL Server started and I launched my Enterprise Manager and checked the "Automatically set I/O affinity mask for all processors".</p>
<p>I then closed the Enterprise Manager, quit the command prompt and started the service. Life was peachy again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentientbeings.com/2010/06/how-to-solve-event-id-17120-sql-server-could-spawn-not-lazy-writer-thread/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

