<?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>Brant Burnett&#039;s Development Blog &#187; SQL Server</title>
	<atom:link href="http://btburnett.com/category/sql-server/feed" rel="self" type="application/rss+xml" />
	<link>http://btburnett.com</link>
	<description></description>
	<lastBuildDate>Tue, 27 Apr 2010 12:48:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Combining Date and Time in DTS To Make a DT_DBTIMESTAMP datetime</title>
		<link>http://btburnett.com/2008/11/combining-date-and-time-in-dts-to-make-a-dt_dbtimestamp-datetime.html</link>
		<comments>http://btburnett.com/2008/11/combining-date-and-time-in-dts-to-make-a-dt_dbtimestamp-datetime.html#comments</comments>
		<pubDate>Tue, 25 Nov 2008 20:16:00 +0000</pubDate>
		<dc:creator>Brant Burnett</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SSIS/DTS]]></category>

		<guid isPermaLink="false">http://www.btburnett.com/?p=26</guid>
		<description><![CDATA[I was recently dealing with importing a DBISAM (Btrieve) database to SQL Server, which had separate date and time columns where I wanted to import a DateTime.  Using the ODBC driver and a DataReader data source, it was returning the date as the DT_DBTIMESTAMP type and the time as a DT_I8 long integer. I tried [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently dealing with importing a DBISAM (Btrieve) database to SQL Server, which had separate date and time columns where I wanted to import a DateTime.  Using the ODBC driver and a DataReader data source, it was returning the date as the DT_DBTIMESTAMP type and the time as a DT_I8 long integer.</p>
<p>I tried using the Derived Column transformation to combine them, but never could get it to work.  There simply aren&#8217;t many date functions supported by the Derived Column formulas.  Finally, I settled on using the following VBS script using the Script Component transformation:<!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode"><span class="kwrd">If</span> <span class="kwrd">Not</span> Row.StartDate_IsNull <span class="kwrd">Then</span>
    <span class="kwrd">If</span> Row.StartTime_IsNull <span class="kwrd">Then</span>
        Row.StartDateTime = Row.StartDate
    <span class="kwrd">Else</span>
        Row.StartDateTime = Row.StartDate.AddTicks(Row.StartTime)
    <span class="kwrd">End</span> <span class="kwrd">If</span>
<span class="kwrd">End</span> If</pre>
]]></content:encoded>
			<wfw:commentRss>http://btburnett.com/2008/11/combining-date-and-time-in-dts-to-make-a-dt_dbtimestamp-datetime.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating GUID Derived Column in DTS</title>
		<link>http://btburnett.com/2008/11/creating-guid-derived-column-in-dts.html</link>
		<comments>http://btburnett.com/2008/11/creating-guid-derived-column-in-dts.html#comments</comments>
		<pubDate>Tue, 25 Nov 2008 19:32:00 +0000</pubDate>
		<dc:creator>Brant Burnett</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SSIS/DTS]]></category>

		<guid isPermaLink="false">http://www.btburnett.com/?p=25</guid>
		<description><![CDATA[If you want to add a constant GUID to a table during a DTS transformation, it&#8217;s a little tricky.  Here&#8217;s the solution. Use the Derived Column transformation in order to add a new column.  For the formula, use the GUID surrounded by double quotes.  The trick is that you MUST include the curly braces, like [...]]]></description>
			<content:encoded><![CDATA[<div>If you want to add a constant GUID to a table during a DTS transformation, it&#8217;s a little tricky.  Here&#8217;s the solution.</p>
<p>Use the Derived Column transformation in order to add a new column.  For the formula, use the GUID surrounded by double quotes.  The trick is that you MUST include the curly braces, like so:</p>
<p>&#8220;{B83030CF-EC5A-45ca-BE2D-BCFCC2A85034}&#8221;</p>
<p>Then set the type of the column to unique identifier (DT_GUID).  That&#8217;s it.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://btburnett.com/2008/11/creating-guid-derived-column-in-dts.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extracting The Date From a SQL DateTime In SQL Queries</title>
		<link>http://btburnett.com/2008/09/extracting-the-date-from-a-sql-datetime-in-sql-queries.html</link>
		<comments>http://btburnett.com/2008/09/extracting-the-date-from-a-sql-datetime-in-sql-queries.html#comments</comments>
		<pubDate>Tue, 30 Sep 2008 14:06:00 +0000</pubDate>
		<dc:creator>Brant Burnett</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.btburnett.com/?p=23</guid>
		<description><![CDATA[Ever wondered how to quickly and easily get the date portion of a datetime field in a SQL query? Seems like it should be easy, right? Unfortunately, it isn&#8217;t. I&#8217;ve found a lot of solutions, but this one is the most elegant I&#8217;ve seen. CONVERT(datetime, FLOOR(CONVERT(float, DateTime))) I&#8217;ve put this into a user-defined function below: [...]]]></description>
			<content:encoded><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml"><small>Ever wondered how to quickly and easily get the date portion of a datetime field in a SQL query?  Seems like it should be easy, right?  Unfortunately, it isn&#8217;t.  I&#8217;ve found a lot of solutions, but this one is the most elegant I&#8217;ve seen.<br /></small>
<pre class="csharpcode"><span class="kwrd">CONVERT</span>(datetime, FLOOR(<span class="kwrd">CONVERT</span>(<span class="kwrd">float</span>, DateTime)))</pre>
<p><small>I&#8217;ve put this into a user-defined function below:<br /></small>
<pre class="csharpcode"><span class="kwrd">SET</span> ANSI_NULLS <span class="kwrd">ON</span><span class="kwrd">GO</span><span class="kwrd">SET</span> QUOTED_IDENTIFIER <span class="kwrd">ON</span><span class="kwrd">GO</span><span class="kwrd">CREATE</span> <span class="kwrd">FUNCTION</span> [dbo].[ExtractDate](   @DateTime datetime)<span class="kwrd">RETURNS</span> datetime<span class="kwrd">AS</span><span class="kwrd">BEGIN</span>   <span class="kwrd">RETURN</span> <span class="kwrd">CONVERT</span>(datetime, FLOOR(<span class="kwrd">CONVERT</span>(<span class="kwrd">float</span>, @DateTime)))<span class="kwrd">END</span></pre>
<p><small>This can be called like so:<br /></small>
<pre class="csharpcode"><span class="kwrd">SELECT</span> dbo.ExtractDate(DateTime) <span class="kwrd">FROM</span> Table</pre>
<p><small>Credit for this conversion method goes to <a href="http://mattberseth.com/">Matt Berseth</a>, i stumbled across it in the example code for something else.<br /></small></div>
]]></content:encoded>
			<wfw:commentRss>http://btburnett.com/2008/09/extracting-the-date-from-a-sql-datetime-in-sql-queries.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005 Service Broker Error Code 25 (Event ID 28054)</title>
		<link>http://btburnett.com/2008/09/sql-server-2005-service-broker-error-code-25-event-id-28054.html</link>
		<comments>http://btburnett.com/2008/09/sql-server-2005-service-broker-error-code-25-event-id-28054.html#comments</comments>
		<pubDate>Tue, 02 Sep 2008 20:06:00 +0000</pubDate>
		<dc:creator>Brant Burnett</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.btburnett.com/?p=22</guid>
		<description><![CDATA[Another issue I&#8217;ve run into with the service broker and moving databases between servers is this error message: Error code:25. The master key has to exist and the service master key encryption is required. The solution that I found was the regenerate the key for the database using the following code: CREATE MASTER KEY ENCRYPTION [...]]]></description>
			<content:encoded><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml"><span id="_ctl0_MainContent_PostFlatView"><span><small>Another issue I&#8217;ve run into with the service broker and moving databases between servers is this error message:<br /></small></span></span><br />
<blockquote><span id="_ctl0_MainContent_PostFlatView"><span><small>Error code:25. The master key has to exist and the service master key encryption is required.</small></span></span><br /><span id="_ctl0_MainContent_PostFlatView"><span></span></span></p></blockquote>
<p><span id="_ctl0_MainContent_PostFlatView"><span><small>The solution that I found was the regenerate the key for the database using the following code:<br /></small></span></span><br />
<blockquote><span id="_ctl0_MainContent_PostFlatView"><span><small>CREATE MASTER KEY ENCRYPTION BY PASSWORD = &#8217;1ComplexPassword!&#8217;</small></span></span><br /><span id="_ctl0_MainContent_PostFlatView"><span></span></span></p></blockquote>
<p><span id="_ctl0_MainContent_PostFlatView"><span><small>You might also need to run the following afterwards:<br /></small></span></span><br />
<blockquote><span id="_ctl0_MainContent_PostFlatView"><span><small>ALTER DATABASE dbname SET NEW_BROKER.</small></span></span><br /><span id="_ctl0_MainContent_PostFlatView"><span></span></span></p></blockquote>
<p><span id="_ctl0_MainContent_PostFlatView"><span><small>Also, see my previous post <a href="http://blog.btburnett.com/2008/05/sql-server-2005-service-broker-error.html">SQL Server 2005 Service Broker Error 15517</a> for another error message and solution.</small></span><br />                                                                                      </span></div>
]]></content:encoded>
			<wfw:commentRss>http://btburnett.com/2008/09/sql-server-2005-service-broker-error-code-25-event-id-28054.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005 Service Broker Error 15517</title>
		<link>http://btburnett.com/2008/05/sql-server-2005-service-broker-error-15517.html</link>
		<comments>http://btburnett.com/2008/05/sql-server-2005-service-broker-error-15517.html#comments</comments>
		<pubDate>Fri, 16 May 2008 17:27:00 +0000</pubDate>
		<dc:creator>Brant Burnett</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.btburnett.com/?p=12</guid>
		<description><![CDATA[Sometimes I&#8217;ve run into the following error in the event log when using the service broker to do SQL command notifications with SQL 2005: An exception occurred while enqueueing a message in the target queue. Error: 15517, State: 1. Cannot execute as the database principal because the principal &#8220;dbo&#8221; does not exist, this type of [...]]]></description>
			<content:encoded><![CDATA[<div xmlns='http://www.w3.org/1999/xhtml'><small>Sometimes I&#8217;ve run into the following error in the event log when using the service broker to do SQL command notifications with SQL 2005:<br/></small><br />
<blockquote><small>An exception occurred while enqueueing a message in the target queue. Error: 15517, State: 1. Cannot execute as the database principal because the principal &#8220;dbo&#8221; does not exist, this type of principal cannot be impersonated, or you do not have permission.</small><br/></p></blockquote>
<p><small>It tends to fill up the event log pretty badly when you see it.  I&#8217;ve especially seen it when I move the database from one server to another.  To fix it, use this command:<br/></small><br />
<blockquote><small>ALTER AUTHORIZATION ON DATABASE::[dbname] TO [SA]</small><br/></p></blockquote>
<p><small>This should fix it for you.<br/></small></div>
]]></content:encoded>
			<wfw:commentRss>http://btburnett.com/2008/05/sql-server-2005-service-broker-error-15517.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
