<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>JustSQL</title>
	<atom:link href="http://justsql.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://justsql.wordpress.com</link>
	<description>SQL DBA in KC</description>
	<lastBuildDate>Thu, 05 Jan 2012 07:45:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='justsql.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/ff57300210e7effd98aea51e04e073c9?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>JustSQL</title>
		<link>http://justsql.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://justsql.wordpress.com/osd.xml" title="JustSQL" />
	<atom:link rel='hub' href='http://justsql.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Trigger and BCP</title>
		<link>http://justsql.wordpress.com/2010/12/29/trigger-and-bcp/</link>
		<comments>http://justsql.wordpress.com/2010/12/29/trigger-and-bcp/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 23:03:45 +0000</pubDate>
		<dc:creator>thejoestory</dc:creator>
				<category><![CDATA[justSQL]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://justsql.wordpress.com/?p=199</guid>
		<description><![CDATA[Working on a cludgy interface between two software vendors, I will call them Vendor A and Vendor B. Vendor B wanted a CSV file every time a certain condition happened in a Vendor A table. First thought was to write a trigger on the table in Vendor A&#8217;s database. After Insert run a query to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=199&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Working on a cludgy interface between two software vendors, I will call them Vendor A and Vendor B. Vendor B wanted a CSV file every time a certain condition happened in a Vendor A table. First thought was to write a trigger on the table in Vendor A&#8217;s database. After Insert run a query to see if the condition is met&#8230;if the condition is met then send data over to a stage table.</p>
<p>Then run a job every minute or so to query the stage table, run some BCP commands to extract the data in a CSV format.</p>
<p><strong>TRIGGER</strong></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">CREATE TRIGGER Trigger on TEST_TABLE</span><br />
<span style="color:#0000ff;"> after insert</span><br />
<span style="color:#0000ff;"> as</span><br />
<span style="color:#0000ff;"> IF EXISTS (SELECT * from TEST_TABLE as c JOIN inserted AS I ON c.column = i.column where i.columnb = &#8216;Condition&#8217;)</span><br />
<span style="color:#0000ff;"> BEGIN</span><br />
<span style="color:#0000ff;"> INSERT INTO stage(column1, column2, column3) SELECT column1, column2, column3 from inserted</span><br />
<span style="color:#0000ff;"> END</span><br />
<span style="color:#0000ff;"> GO</span></p>
<p><strong>Export Call</strong></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">declare @cmd varchar(2000)</span><br />
<span style="color:#0000ff;"> select @cmd = &#8216;bcp &#8220;select * from stage&#8221; queryout c:\audit_&#8217;+convert(varchar(8),getdate(),112)+&#8217;_'+Replace(CONVERT(CHAR(8),(CONVERT(DATETIME,CURRENT_TIMESTAMP,113)),114), &#8216;:&#8217;, &#8221;)+&#8217;.csv -t, -T -c&#8217;</span><br />
<span style="color:#0000ff;"> EXEC xp_cmdshell @cmd</span><br />
<span style="color:#0000ff;"> GO</span><br />
<span style="color:#0000ff;"> delete from stage</span></p>
<p>The <span style="color:#0000ff;">Replace(CONVERT(CHAR(8),(CONVERT(DATETIME,CURRENT_TIMESTAMP,113)),114), &#8216;:&#8217;, &#8221;)</span> gives me miltary time&#8230;like that a lot. I will store that for later use.</p>
<p>Anyway, this works pretty well in testing. May need to make some tweaks before going live. I first tried running the BCP in the trigger itself, but had the trigger freeze problem that others reported and read some articles about how this is probably not the best idea. This way is not as realtime, but works well for what I need.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justsql.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justsql.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justsql.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justsql.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justsql.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justsql.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justsql.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justsql.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justsql.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justsql.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justsql.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justsql.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justsql.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justsql.wordpress.com/199/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=199&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justsql.wordpress.com/2010/12/29/trigger-and-bcp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81cb0c102753befe72cb77be9218b26b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thejoestory</media:title>
		</media:content>
	</item>
		<item>
		<title>Grant Execute Permissions for all Stored Procedures 2005</title>
		<link>http://justsql.wordpress.com/2010/10/01/granting-execute-permissions-for-all-stored-procedures-2005/</link>
		<comments>http://justsql.wordpress.com/2010/10/01/granting-execute-permissions-for-all-stored-procedures-2005/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 16:29:43 +0000</pubDate>
		<dc:creator>thejoestory</dc:creator>
				<category><![CDATA[justSQL]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://justsql.wordpress.com/?p=193</guid>
		<description><![CDATA[Like the new Database Scope feature in 2005 as concerned with Granting execute permissions. You can now create a role and then grant execute at the Database level to give the role execute permissions on all stored procedures: /* CREATE A NEW ROLE */ CREATE ROLE db_executor /* GRANT EXECUTE TO THE ROLE */ GRANT [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=193&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Like the new Database Scope feature in 2005 as concerned with Granting execute permissions. You can now create a role and then grant execute at the Database level to give the role execute permissions on all stored procedures:</p>
<p><span style="color:#0000ff;">/* CREATE A NEW ROLE */<br />
CREATE ROLE db_executor</span></p>
<p><span style="color:#0000ff;">/* GRANT EXECUTE TO THE ROLE */<br />
GRANT EXECUTE TO db_exec</span><span style="color:#0000ff;">utor</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justsql.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justsql.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justsql.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justsql.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justsql.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justsql.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justsql.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justsql.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justsql.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justsql.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justsql.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justsql.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justsql.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justsql.wordpress.com/193/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=193&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justsql.wordpress.com/2010/10/01/granting-execute-permissions-for-all-stored-procedures-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81cb0c102753befe72cb77be9218b26b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thejoestory</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL State 42000 Rebuild Index</title>
		<link>http://justsql.wordpress.com/2010/09/21/sql-state-42000-rebuild-index/</link>
		<comments>http://justsql.wordpress.com/2010/09/21/sql-state-42000-rebuild-index/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 18:26:15 +0000</pubDate>
		<dc:creator>thejoestory</dc:creator>
				<category><![CDATA[justSQL]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://justsql.wordpress.com/?p=190</guid>
		<description><![CDATA[So when using this script USE [database name] GO exec sp_MSForEachtable @command1=”ALTER INDEX ALL ON ? REBUILD” GO exec sp_MSForEachtable @command1=”UPDATE STATISTICS ? WITH FULLSCAN” GO I started to receive this error message: ALTER INDEX failed because the following SET options have incorrect settings: &#8216;QUOTED_IDENTIFIER&#8217;. Verify that SET options are correct for use with indexed [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=190&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So when using this script</p>
<blockquote><p>USE [database name]<br />
GO<br />
exec sp_MSForEachtable @command1=”ALTER INDEX ALL ON ? REBUILD”<br />
GO<br />
exec sp_MSForEachtable @command1=”UPDATE STATISTICS ? WITH FULLSCAN”<br />
GO</p></blockquote>
<p>I started to receive this error message:</p>
<blockquote><p>ALTER INDEX failed because the following SET options have incorrect settings: &#8216;QUOTED_IDENTIFIER&#8217;. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or query notifications and/or xml data type methods. [SQLSTATE 42000]</p></blockquote>
<p>When you try to rebuild a indexed view or a computed column you will run into this error. I quickly tried adding a SET QUOTED_IDENTIFIER ON to the top of my query but after some reading found out that this has no impact when using the sp_MSForEachTable.</p>
<p>For now I created a DB Maintenance Plan to rebuild the indexes and recompute the statistics. Another way around the issue would be to build a custom script/stored procedure to loop through all the tables in sys.objects (where type = &#8216;U&#8217; and then using the SET statement before each ALTER INDEX statement.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justsql.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justsql.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justsql.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justsql.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justsql.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justsql.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justsql.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justsql.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justsql.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justsql.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justsql.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justsql.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justsql.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justsql.wordpress.com/190/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=190&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justsql.wordpress.com/2010/09/21/sql-state-42000-rebuild-index/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81cb0c102753befe72cb77be9218b26b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thejoestory</media:title>
		</media:content>
	</item>
		<item>
		<title>Rebuild all Indexes and Update Statistics</title>
		<link>http://justsql.wordpress.com/2010/08/30/rebuild-all-indexes-and-update-statistics/</link>
		<comments>http://justsql.wordpress.com/2010/08/30/rebuild-all-indexes-and-update-statistics/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 15:27:30 +0000</pubDate>
		<dc:creator>thejoestory</dc:creator>
				<category><![CDATA[justSQL]]></category>
		<category><![CDATA[automation]]></category>

		<guid isPermaLink="false">http://justsql.wordpress.com/?p=185</guid>
		<description><![CDATA[Here is a quick script to rebuild all indexes and update statistics for you database: USE [database name] GO exec sp_MSForEachtable @command1=&#8221;ALTER INDEX ALL ON ? REBUILD&#8221; GO exec sp_MSForEachtable @command1=&#8221;UPDATE STATISTICS ? WITH FULLSCAN&#8221; GO<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=185&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a quick script to rebuild all indexes and update statistics for you database:</p>
<p><span style="color:#0000ff;">USE [database name]<br />
GO<br />
exec sp_MSForEachtable @command1=&#8221;ALTER INDEX ALL ON ? REBUILD&#8221;<br />
GO<br />
exec sp_MSForEachtable @command1=&#8221;UPDATE STATISTICS ? WITH FULLSCAN&#8221;<br />
GO</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justsql.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justsql.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justsql.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justsql.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justsql.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justsql.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justsql.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justsql.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justsql.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justsql.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justsql.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justsql.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justsql.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justsql.wordpress.com/185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=185&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justsql.wordpress.com/2010/08/30/rebuild-all-indexes-and-update-statistics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81cb0c102753befe72cb77be9218b26b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thejoestory</media:title>
		</media:content>
	</item>
		<item>
		<title>Error 14274</title>
		<link>http://justsql.wordpress.com/2010/08/16/error-14274/</link>
		<comments>http://justsql.wordpress.com/2010/08/16/error-14274/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 15:48:23 +0000</pubDate>
		<dc:creator>thejoestory</dc:creator>
				<category><![CDATA[justSQL]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[jobs]]></category>

		<guid isPermaLink="false">http://justsql.wordpress.com/?p=180</guid>
		<description><![CDATA[So I was trying to modify some of my SQL Agent jobs and I got an Error: 14274. Wild. Background: We had to rename our production server after software upgrade this weekend. We did not want anyone hitting the old server. The problem started. Solution: 1. Run a select @@SERVERNAME. Verify that you have the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=180&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So I was trying to modify some of my SQL Agent jobs and I got an Error: 14274. Wild.</p>
<p style="text-align:center;"><a href="http://justsql.files.wordpress.com/2010/06/error14274.png"><img class="size-full wp-image-183 aligncenter" title="error14274" src="http://justsql.files.wordpress.com/2010/06/error14274.png?w=500&#038;h=63" alt="" width="500" height="63" /></a></p>
<p><strong>Background:</strong><br />
We had to rename our production server after software upgrade this weekend. We did not want anyone hitting the old server. The problem started.</p>
<p><strong>Solution: </strong></p>
<p>1. Run a select @@SERVERNAME. Verify that you have the correct server name. The server name was incorrect due to the server rename so I had to run the following commands:<br />
sp_dropserver &#8216;Old Server Name&#8217;</p>
<p>sp_addserver &#8216;New Server Name&#8217;</p>
<p>You then have to restart the SQL Service. Once you restart run the select @@SERVERNAME command again and verify the name is correct.</p>
<p>2. Select * from msdb..sysjobs. This will show you the Originating Server Column. In my case this was the original server name.</p>
<p>3. Run an update statement to fix the server name: update sysjobs set originating_server = &#8216;New Server Name&#8217; where originating_server = &#8216;Old Server Name&#8217;</p>
<p>After that final update statement I was then able to update/edit/delete the jobs.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justsql.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justsql.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justsql.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justsql.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justsql.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justsql.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justsql.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justsql.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justsql.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justsql.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justsql.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justsql.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justsql.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justsql.wordpress.com/180/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=180&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justsql.wordpress.com/2010/08/16/error-14274/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81cb0c102753befe72cb77be9218b26b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thejoestory</media:title>
		</media:content>

		<media:content url="http://justsql.files.wordpress.com/2010/06/error14274.png" medium="image">
			<media:title type="html">error14274</media:title>
		</media:content>
	</item>
		<item>
		<title>Changed database context to</title>
		<link>http://justsql.wordpress.com/2010/06/18/changed-database-context-to/</link>
		<comments>http://justsql.wordpress.com/2010/06/18/changed-database-context-to/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 15:36:06 +0000</pubDate>
		<dc:creator>thejoestory</dc:creator>
				<category><![CDATA[justSQL]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://justsql.wordpress.com/?p=177</guid>
		<description><![CDATA[It has been a while since my last post. Ill use the standard excuses of &#8220;i was busy&#8221; and &#8220;i&#8217;m on vacation&#8221;. Ran across an interesting error message today working on a VBScript. That blackout portion is my database name. The script is a simple script to query a database and dump some data into [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=177&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It has been a while since my last post. Ill use the standard excuses of &#8220;i was busy&#8221; and &#8220;i&#8217;m on vacation&#8221;. Ran across an interesting error message today working on a VBScript.</p>
<p><a href="http://justsql.files.wordpress.com/2010/06/errorvb.png"><img class="aligncenter size-full wp-image-178" title="errorVB" src="http://justsql.files.wordpress.com/2010/06/errorvb.png?w=500&#038;h=148" alt="" width="500" height="148" /></a></p>
<p>That blackout portion is my database name. The script is a simple script to query a database and dump some data into a .csv. Well the error started driving me crazy. The code looked correct. I kept pouring over the code again and again looking for an answer.</p>
<p>Did some google searches and did not find a whole lot of information. Finally the answer hit me. While running the script I kept opening it up in a text editor. The resulting CSV is really wide and my header column data is longer than the data in the rows. So one time I opened the CSV in Excel to see the data lined up a little better.</p>
<p>Well I forgot to close the CSV in Excel before running the script again. The error message threw me off. Instead of saying something like access denied or permission denied, it gives me some wild context changed error.</p>
<p>Oh well, I closed down Excel and badda-bing.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justsql.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justsql.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justsql.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justsql.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justsql.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justsql.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justsql.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justsql.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justsql.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justsql.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justsql.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justsql.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justsql.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justsql.wordpress.com/177/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=177&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justsql.wordpress.com/2010/06/18/changed-database-context-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81cb0c102753befe72cb77be9218b26b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thejoestory</media:title>
		</media:content>

		<media:content url="http://justsql.files.wordpress.com/2010/06/errorvb.png" medium="image">
			<media:title type="html">errorVB</media:title>
		</media:content>
	</item>
		<item>
		<title>Backup Database to UNC</title>
		<link>http://justsql.wordpress.com/2010/04/26/backup-database-to-unc/</link>
		<comments>http://justsql.wordpress.com/2010/04/26/backup-database-to-unc/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 20:23:33 +0000</pubDate>
		<dc:creator>thejoestory</dc:creator>
				<category><![CDATA[justSQL]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://justsql.wordpress.com/?p=174</guid>
		<description><![CDATA[Mainly to remind me how to backup from SQL Server to a UNC, but maybe this will provide you with a quick step by step and save you some time. Details, performing a Full Database Backup of a SQL Server 2000 database to a UNC. Both the source and destination servers are in the same [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=174&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Mainly to remind me how to backup from SQL Server to a UNC, but maybe this will provide you with a quick step by step and save you some time. Details, performing a Full Database Backup of a SQL Server 2000 database to a UNC. Both the source and destination servers are in the same domain. The SQL Server Service and the SQL Server Agent Service are both started using a domain account.</p>
<ol>
<li>Set the SQL Server Server service to start as a domain account that has appropriate permissions (Read/Write) to your UNC path</li>
<li>Run the setspn tool to register your domain user servicePrincipalName field in AD. You can use ADSIEDIT.msc console to check the status of the command. setspn MSSQLSvc/ServerName.domain.com Domain\User [see my Epic quest article for more details]</li>
<li>Create the SQL backup job to backup the database to the UNC path: BACKUP DATABASE [dbname] TO  DISK = N&#8217;\\servername\share_name\filename.bak&#8217; WITH  INIT ,  NOUNLOAD ,  NAME = N&#8217;backup name&#8217;,  NOSKIP ,  STATS = 10,  NOFORMAT</li>
<li>Celebrate a job well done, perhaps with a Mt. Dew or your choice of work approved beverage.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justsql.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justsql.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justsql.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justsql.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justsql.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justsql.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justsql.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justsql.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justsql.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justsql.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justsql.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justsql.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justsql.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justsql.wordpress.com/174/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=174&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justsql.wordpress.com/2010/04/26/backup-database-to-unc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81cb0c102753befe72cb77be9218b26b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thejoestory</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server Deadlock</title>
		<link>http://justsql.wordpress.com/2010/04/26/sql-server-deadlock/</link>
		<comments>http://justsql.wordpress.com/2010/04/26/sql-server-deadlock/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 13:17:37 +0000</pubDate>
		<dc:creator>thejoestory</dc:creator>
				<category><![CDATA[justSQL]]></category>
		<category><![CDATA[deadlock]]></category>

		<guid isPermaLink="false">http://justsql.wordpress.com/?p=166</guid>
		<description><![CDATA[Only about a million articles exist on deadlocks, tracing deadlocks,etc. I thought I would add to the number and make the count million one. From Books Online: &#8220;A deadlock occurs when two or more tasks permanently block each other by each task having a lock on a resource which the other tasks are trying to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=166&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Only about a million articles exist on deadlocks, tracing deadlocks,etc. I thought I would add to the number and make the count million one.</p>
<p>From Books Online:<br />
&#8220;A deadlock occurs when two or more tasks permanently block each other by each task having a lock on a resource which the other tasks are trying to lock. The SQL Server Database Engine automatically detects deadlock cycles within SQL Server&#8230;The Database Engine chooses one of the sessions as a deadlock victim and the current transaction is terminated with an error to break the deadlock.&#8221;</p>
<p>Man I am only a paragraph in and I am sleepy. Must be because it is Monday. Anyway I went ahead and fired up some trace flags on my instance:</p>
<p style="padding-left:30px;"><span style="color:#0000ff;">DBCC TRACEON (1204,1205,3605, -1)<br />
GO<br />
DBCC TRACESTATUS(-1)<br />
GO</span></p>
<ul>
<li><strong>Trace 1204</strong> reports deadlock information formatted by each node involved in the deadlock.</li>
<li><strong>Trace 1222</strong> formats deadlock information, first by process and then by resources.</li>
<li><strong>Trace 1205</strong> returns more detailed information about he command being executed at the time of the deadlock. This flag is now undocumented.</li>
<li><strong>Trace 3605</strong> sends trace output to the error log.</li>
</ul>
<p>You can set these trace events as start up parameters if you desire, however you will need to bounce the service to make it happen.</p>
<p>After I turned on the traces listed above, I fired up a SQL Server Profiler and started a profile using these Events: Deadlock Graph, Lock:Deadlock, and Lock:Deadlock Chain.</p>
<p>And now we wait&#8230;.and wait&#8230;Wondering if a deadlock will happen. My next step is to setup my deadlock profiler trace as a server side trace so I do not have to leave profiler up and running.</p>
<p>UPDATE: Converted the profiler trace into a server side trace. Just hop into profiler, configure your trace, start the trace, stop the trace. Then use the Export/Script Trace Definition&#8230;under the file menu. This will generate a .SQL script to execute to fire up the trace. You will need to insert a trace file path and name. Then once you execute the script the server side trace will start.</p>
<p>Example of the trace definition for the above Deadlock trace:</p>
<p style="padding-left:30px;"><span style="color:#0000ff;">/****************************************************/<br />
/* Created by: SQL Server Profiler 2005             */<br />
/* Date: 04/26/2010  08:19:16 AM         */<br />
/****************************************************/</span></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">&#8211; Create a Queue<br />
declare @rc int<br />
declare @TraceID int<br />
declare @maxfilesize bigint<br />
set @maxfilesize = 5</span></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">&#8211; Please replace the text InsertFileNameHere, with an appropriate<br />
&#8211; filename prefixed by a path, e.g., c:\MyFolder\MyTrace. The .trc extension<br />
&#8211; will be appended to the filename automatically. If you are writing from<br />
&#8211; remote server to local drive, please use UNC path and make sure server has<br />
&#8211; write access to your network share</span></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">exec @rc = sp_trace_create @TraceID output, 0, N&#8217;e:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\Deadlock_Trace.trc&#8217;, @maxfilesize, NULL<br />
if (@rc != 0) goto error</span></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">&#8211; Client side File and Table cannot be scripted</span></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">&#8211; Set the events<br />
declare @on bit<br />
set @on = 1<br />
exec sp_trace_setevent @TraceID, 148, 11, @on<br />
exec sp_trace_setevent @TraceID, 148, 51, @on<br />
exec sp_trace_setevent @TraceID, 148, 4, @on<br />
exec sp_trace_setevent @TraceID, 148, 12, @on<br />
exec sp_trace_setevent @TraceID, 148, 14, @on<br />
exec sp_trace_setevent @TraceID, 148, 26, @on<br />
exec sp_trace_setevent @TraceID, 148, 60, @on<br />
exec sp_trace_setevent @TraceID, 148, 64, @on<br />
exec sp_trace_setevent @TraceID, 148, 1, @on<br />
exec sp_trace_setevent @TraceID, 148, 41, @on<br />
exec sp_trace_setevent @TraceID, 25, 7, @on<br />
exec sp_trace_setevent @TraceID, 25, 15, @on<br />
exec sp_trace_setevent @TraceID, 25, 55, @on<br />
exec sp_trace_setevent @TraceID, 25, 8, @on<br />
exec sp_trace_setevent @TraceID, 25, 32, @on<br />
exec sp_trace_setevent @TraceID, 25, 56, @on<br />
exec sp_trace_setevent @TraceID, 25, 64, @on<br />
exec sp_trace_setevent @TraceID, 25, 1, @on<br />
exec sp_trace_setevent @TraceID, 25, 9, @on<br />
exec sp_trace_setevent @TraceID, 25, 25, @on<br />
exec sp_trace_setevent @TraceID, 25, 41, @on<br />
exec sp_trace_setevent @TraceID, 25, 49, @on<br />
exec sp_trace_setevent @TraceID, 25, 57, @on<br />
exec sp_trace_setevent @TraceID, 25, 2, @on<br />
exec sp_trace_setevent @TraceID, 25, 10, @on<br />
exec sp_trace_setevent @TraceID, 25, 26, @on<br />
exec sp_trace_setevent @TraceID, 25, 58, @on<br />
exec sp_trace_setevent @TraceID, 25, 3, @on<br />
exec sp_trace_setevent @TraceID, 25, 11, @on<br />
exec sp_trace_setevent @TraceID, 25, 35, @on<br />
exec sp_trace_setevent @TraceID, 25, 51, @on<br />
exec sp_trace_setevent @TraceID, 25, 4, @on<br />
exec sp_trace_setevent @TraceID, 25, 12, @on<br />
exec sp_trace_setevent @TraceID, 25, 52, @on<br />
exec sp_trace_setevent @TraceID, 25, 60, @on<br />
exec sp_trace_setevent @TraceID, 25, 13, @on<br />
exec sp_trace_setevent @TraceID, 25, 6, @on<br />
exec sp_trace_setevent @TraceID, 25, 14, @on<br />
exec sp_trace_setevent @TraceID, 25, 22, @on<br />
exec sp_trace_setevent @TraceID, 59, 55, @on<br />
exec sp_trace_setevent @TraceID, 59, 32, @on<br />
exec sp_trace_setevent @TraceID, 59, 56, @on<br />
exec sp_trace_setevent @TraceID, 59, 64, @on<br />
exec sp_trace_setevent @TraceID, 59, 1, @on<br />
exec sp_trace_setevent @TraceID, 59, 21, @on<br />
exec sp_trace_setevent @TraceID, 59, 25, @on<br />
exec sp_trace_setevent @TraceID, 59, 41, @on<br />
exec sp_trace_setevent @TraceID, 59, 49, @on<br />
exec sp_trace_setevent @TraceID, 59, 57, @on<br />
exec sp_trace_setevent @TraceID, 59, 2, @on<br />
exec sp_trace_setevent @TraceID, 59, 14, @on<br />
exec sp_trace_setevent @TraceID, 59, 22, @on<br />
exec sp_trace_setevent @TraceID, 59, 26, @on<br />
exec sp_trace_setevent @TraceID, 59, 58, @on<br />
exec sp_trace_setevent @TraceID, 59, 3, @on<br />
exec sp_trace_setevent @TraceID, 59, 35, @on<br />
exec sp_trace_setevent @TraceID, 59, 51, @on<br />
exec sp_trace_setevent @TraceID, 59, 4, @on<br />
exec sp_trace_setevent @TraceID, 59, 12, @on<br />
exec sp_trace_setevent @TraceID, 59, 52, @on<br />
exec sp_trace_setevent @TraceID, 59, 60, @on</span></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">&#8211; Set the Filters<br />
declare @intfilter int<br />
declare @bigintfilter bigint</span></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">&#8211; Set the trace status to start<br />
exec sp_trace_setstatus @TraceID, 1</span></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">&#8211; display trace id for future references<br />
select TraceID=@TraceID<br />
goto finish</span></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">error:<br />
select ErrorCode=@rc</span></p>
<p style="padding-left:30px;"><span style="color:#0000ff;">finish:<br />
go</span></p>
<p style="padding-left:30px;">
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justsql.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justsql.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justsql.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justsql.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justsql.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justsql.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justsql.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justsql.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justsql.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justsql.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justsql.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justsql.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justsql.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justsql.wordpress.com/166/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=166&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justsql.wordpress.com/2010/04/26/sql-server-deadlock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81cb0c102753befe72cb77be9218b26b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thejoestory</media:title>
		</media:content>
	</item>
		<item>
		<title>Import Multiple XML files into Access</title>
		<link>http://justsql.wordpress.com/2010/03/25/import-multiple-xml-files-into-access/</link>
		<comments>http://justsql.wordpress.com/2010/03/25/import-multiple-xml-files-into-access/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 18:11:55 +0000</pubDate>
		<dc:creator>thejoestory</dc:creator>
				<category><![CDATA[justSQL]]></category>
		<category><![CDATA[automation]]></category>

		<guid isPermaLink="false">http://justsql.wordpress.com/?p=162</guid>
		<description><![CDATA[So boss emails me and asks hey can you import 2,900 XML files into this attached Access database. Of course I say sure thing, no sweat. I knew this I was not the first person in the world with the need to import XML files into access so was confident I could find something on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=162&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So boss emails me and asks hey can you import 2,900 XML files into this attached Access database. Of course I say sure thing, no sweat. I knew this I was not the first person in the world with the need to import XML files into access so was confident I could find something on Google to facilitate.</p>
<p>The first thought I had was just throwing the data in a SQL Server database (boss mentioned SQL Server is a fine destination also) using an SSIS pacakge. I know SSIS has a sweet foreach loop container. Optimistically I fired up the Visual Studio designer, thinking that I would actually be able to figure this SSIS thing out pretty quick.</p>
<p>Wrong. Man I do have a desire to learn SSIS (well I at least tell myself I do) but every time I sit down to actually do it, I get flustered and think of an easier way to perform the task in a VBScript, DTS Package, etc.</p>
<p>I went back to Google thinking there had to be some freeware software out there to help with the import. The closest I found was some shareware version of an multi-file XML import. However with the shareware version you could only work with one file at a time. No thanks.</p>
<p>After uninstalling the shareware software, I stumbled on<a href="http://technet.microsoft.com/en-us/library/ee692914.aspx"> this article</a> from Technet. This looks way to easy to actually work was my first thought.</p>
<p style="padding-left:30px;"><span style="color:#0000ff;">Set objAccess = CreateObject(&#8220;Access.Application&#8221;)<br />
objAccess.OpenCurrentDatabase &#8220;C:\Scripts\Test.mdb&#8221;<br />
objAccess.ImportXML &#8220;c:\scripts\test.xml&#8221;, acAppendData</span></p>
<p>That&#8217;s it??? Really is it that simple? I fired up my Notepad++ and quickly modified the script to line up with my file paths. Double clicked on the resulting VBS file and poof like magic the XML files were importing. So then I just wrapped a Files Collection around it and whamo, I am watching wscript.exe do the rest. So simple.</p>
<p style="padding-left:30px;">Final Script:</p>
<p><span style="color:#0000ff;">Set objAccess = CreateObject(&#8220;Access.Application&#8221;)<br />
objAccess.OpenCurrentDatabase &#8220;c:\Scripts\db3.mdb&#8221;<br />
set fso = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br />
Set f = fso.GetFolder(&#8220;C:\XML&#8221;)<br />
Set fc = f.Files<br />
For Each f1 in fc<br />
objAccess.ImportXML f1.Path, acAppendData<br />
Next</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justsql.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justsql.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justsql.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justsql.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justsql.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justsql.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justsql.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justsql.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justsql.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justsql.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justsql.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justsql.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justsql.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justsql.wordpress.com/162/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=162&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justsql.wordpress.com/2010/03/25/import-multiple-xml-files-into-access/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81cb0c102753befe72cb77be9218b26b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thejoestory</media:title>
		</media:content>
	</item>
		<item>
		<title>Server Role vs Database Role</title>
		<link>http://justsql.wordpress.com/2010/03/09/server-role-vs-database-role/</link>
		<comments>http://justsql.wordpress.com/2010/03/09/server-role-vs-database-role/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 14:55:04 +0000</pubDate>
		<dc:creator>thejoestory</dc:creator>
				<category><![CDATA[justSQL]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://justsql.wordpress.com/?p=157</guid>
		<description><![CDATA[I needed a little refresher the other day on Server roles vs. Database roles in SQL Server 2000. So I created a SQL User called test and gave him no access. I then opened up a query analyzer window and logged in as my new user. I was able to login successfully. I could see [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=157&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I needed a little refresher the other day on Server roles vs.  Database roles in SQL Server 2000. So I created a SQL User called test  and gave him no access. I then opened up a query analyzer window and  logged in as my new user. I was able to login successfully. I could see  master, msdb, and tempdb in the database dropdown box. I tried a quick  query on msdb:</p>
<p>select * from sysjobs</p>
<p>Result: Server: Msg  229, Level 14, State 5, Line 1<br />
SELECT permission denied on object &#8216;sysjobs&#8217;, database &#8216;msdb&#8217;, owner  &#8216;dbo&#8217;.</p>
<p>However using the stored procedure  sp_helprotect, I  started to determine what access my test user had to each database. From  BOL: SP_HELPROTECT: Returns a report with information about user  permissions for an object, or  statement permissions, in the current  database. After running this against a user against on the master and  msdb you quickly realize that the default created user has a lot of  access.</p>
<p>The default user can glean the following information (and a lot  more)</p>
<ul>
<li>Database file location, name, etc from sysfiles in msdb</li>
<li>User information from sysusers</li>
<li>User information from syslogins. Syslogins is interesting because  if you do a SELECT * from it you get the permissions error. Inspection  of the output from the sp_helprotect shows which columns in syslogins  that you have access to. So just alter your select to select the fields  you have access to.</li>
<li>Information about objects from the sysobjects table</li>
<li>Etc. Etc.</li>
</ul>
<p>It feels like I am just scratching the surface. In the weeks to come I am going to set aside some time to come up with a security audit technique. Anyway, to continue  on with my testing I then gave the user some fixed server roles.  Tested some queries, rinse repeat, etc.</p>
<p>Lessons Learned (or  re-learned):</p>
<ul>
<li>Do not give sysadmin fixed server role out unless it is absolutely  justified.</li>
<li>Default users with no access have quite a bit of access to the  information about your server/database</li>
<li>Used the database roles to give access to specific databases, used  the fixed server roles to give access server wide.</li>
<li>Be as granular as possible when diving out permissions</li>
<li>Use the sp_helprotect stored procedure to audit what permissions a  user has. Make sure application users do not have to many permissions.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justsql.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justsql.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justsql.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justsql.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justsql.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justsql.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justsql.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justsql.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justsql.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justsql.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justsql.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justsql.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justsql.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justsql.wordpress.com/157/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justsql.wordpress.com&amp;blog=10052112&amp;post=157&amp;subd=justsql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justsql.wordpress.com/2010/03/09/server-role-vs-database-role/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81cb0c102753befe72cb77be9218b26b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thejoestory</media:title>
		</media:content>
	</item>
	</channel>
</rss>
