<?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>The other blog of Miguel Pereira</title>
	<atom:link href="http://www.myrotarycar.com/blog/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.myrotarycar.com/blog</link>
	<description>The BLOG where technology, music, science &#38; irrelevance all meet and melt</description>
	<lastBuildDate>Thu, 04 Mar 2010 21:11:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dream Theater in Dallas June 9th 2010</title>
		<link>http://www.myrotarycar.com/blog/index.php/2010/03/04/dream-theater-in-dallas-june-9th-2010/</link>
		<comments>http://www.myrotarycar.com/blog/index.php/2010/03/04/dream-theater-in-dallas-june-9th-2010/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 20:57:20 +0000</pubDate>
		<dc:creator>Miguel Pereira</dc:creator>
				<category><![CDATA[Dream Theater]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[dream theater]]></category>
		<category><![CDATA[iron maiden]]></category>
		<category><![CDATA[us tour]]></category>

		<guid isPermaLink="false">http://www.myrotarycar.com/blog/?p=805</guid>
		<description><![CDATA[And finally I get to see them live after 3 years; not only that, but this time around they are the opening act for another band. A band from across the pond. A band call IRON MAIDEN!!!!!!
Here are the press releases from both Dream Theater &#38; Iron Maiden&#8217;s sites:
http://dreamtheater.net/news_dreamtheater.php#dtmaiden
http://www.ironmaiden.com/index.php?categoryid=8&#38;p2_articleid=1183
Tickets go on sale to the public [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">And finally I get to see them live after 3 years; not only that, but this time around they are the opening act for another band. A band from across the pond. A band call IRON MAIDEN!!!!!!</p>
<p style="text-align: justify;">Here are the press releases from both Dream Theater &amp; Iron Maiden&#8217;s sites:</p>
<p>http://dreamtheater.net/news_dreamtheater.php#dtmaiden</p>
<p>http://www.ironmaiden.com/index.php?categoryid=8&amp;p2_articleid=1183</p>
<p style="text-align: justify;">Tickets go on sale to the public on 3/20/2010 &amp; 3/13/2010 for Iron Maiden fan club members. Guess what? I am a proud new member of the Iron Maiden fan club as of 5 minutes ago. I have not been this excited since DT announced the release of BCSL <img src='http://www.myrotarycar.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: justify;">Here are the rest of the US Tour Dates:</p>
<div class="codecolorer-container text geshi" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:450px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">**THE FINAL FRONTIER 2010 NORTH AMERICAN TOUR**<br />
JUNE<br />
Wed 09&nbsp; Dallas,TX &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Superpages.com Center<br />
Fri 11&nbsp; Houston,TX &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cynthia Woods Mitchell Pavilion<br />
Sat 12&nbsp; San Antonio,TX &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AT&amp;T Center<br />
Mon 14&nbsp; Denver,CO &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Comfort Dental Amphitheatre<br />
Wed 16&nbsp; Albuquerque,NM &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; The Pavilion <br />
Thu 17&nbsp; Phoenix,AZ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cricket Wireless Pavilion<br />
Sat 19&nbsp; San Bernardino,CA &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;San Manuel Amphitheatre<br />
Sun 20&nbsp; Concord,CA &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sleep Train Pavilion<br />
Tue 22&nbsp; Auburn,WA &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;White River Amphitheatre<br />
Thu 24&nbsp; Vancouver,BC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GM Place<br />
Sat 26&nbsp; Edmonton,AB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Rexall Place        <br />
Tue 29&nbsp; Saskatoon,SK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Credit Union Centre   <br />
Wed 30&nbsp; Winnipeg,MB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MTSCentre+<br />
<br />
JULY<br />
Sat 03&nbsp; Toronto,ON &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Molson Amphitheatre<br />
Wed 07&nbsp; Montreal,QC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Bell Centre*<br />
Sun 11&nbsp; Holmdel,NJ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PNC<br />
Mon 12&nbsp; New York,NY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Madison Square Garden++<br />
Wed 14&nbsp; Pittsburgh,PA &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;First Niagara Pavilion<br />
Thu 15&nbsp; Cleveland,OH &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Blossom Music Center<br />
Sat 17&nbsp; Detroit,MI &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DTE Energy Music Theatre<br />
Sun 18&nbsp; Chicago,IL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; First Midwest Bank Amphitheatre<br />
Tue 20&nbsp; Washington D.C. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Jiffy Lube Live</div></td></tr></tbody></table></div>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/03/04/dream-theater-in-dallas-june-9th-2010/" target="_blank"><img src="http://www.myrotarycar.com/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/03/04/dream-theater-in-dallas-june-9th-2010/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://www.myrotarycar.com/blog/index.php/2010/03/04/dream-theater-in-dallas-june-9th-2010/&title=Dream Theater in Dallas June 9th 2010" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.myrotarycar.com/blog/index.php/feed/rss/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://www.myrotarycar.com/blog/index.php/2010/03/04/dream-theater-in-dallas-june-9th-2010/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://www.myrotarycar.com/blog/index.php/2010/03/04/dream-theater-in-dallas-june-9th-2010/&title=Dream Theater in Dallas June 9th 2010" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://www.myrotarycar.com/blog/index.php/2010/03/04/dream-theater-in-dallas-june-9th-2010/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://www.myrotarycar.com/blog/index.php/2010/03/04/dream-theater-in-dallas-june-9th-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Aiding the suffering new Oracle DBA</title>
		<link>http://www.myrotarycar.com/blog/index.php/2010/02/24/aiding-the-suffering-new-oracle-dba/</link>
		<comments>http://www.myrotarycar.com/blog/index.php/2010/02/24/aiding-the-suffering-new-oracle-dba/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 10:38:42 +0000</pubDate>
		<dc:creator>Miguel Pereira</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.myrotarycar.com/blog/?p=797</guid>
		<description><![CDATA[&#8230;or the newly Microsoft SQL DBA converted to Oracle by proxy. I think I may be posting quite a few of these in the upcoming days while I slowly move deeper into Oracle DBA territory. The learning curve will be steep, but hope it will be a rewarding trip. Enough nonsense though. Here we go.
Comparing [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">&#8230;or the newly Microsoft SQL DBA converted to Oracle by proxy. I think I may be posting quite a few of these in the upcoming days while I slowly move deeper into Oracle DBA territory. The learning curve will be steep, but hope it will be a rewarding trip. Enough nonsense though. Here we go.</p>
<h3 style="text-align: justify;">Comparing Microsoft SQL 200x vs Oracle 11g</h3>
<p style="text-align: justify;"><a href="http://www.psoug.org/reference/sqlserver.html">http://www.psoug.org/reference/sqlserver.html</a></p>
<p style="text-align: justify;">Priceless! Quite possibly the holy grail of guides out there in helping us understand the basic differences with Oracle.</p>
<h3 style="text-align: justify;">Migrating hard to -or impossible to- convert data types from SQL to Oracle</h3>
<p style="text-align: justify;"><a href="http://www.oracle.com/technology/obe/hol08/sqldev_migration/mssqlserver/migrate_microsoft_sqlserver_otn.htm">http://www.oracle.com/technology/obe/hol08/sqldev_migration/mssqlserver/migrate_microsoft_sqlserver_otn.htm</a></p>
<p style="text-align: justify;">Credit goes out to my boss for finding this while I was treading water trying to figure out how to pump data from a SQL2005 [text] data type to an Oracle [CLOB] column across a linked server using Openquery. The method presented by Oracle is far more complex and lenghty but it works.</p>
<p style="text-align: justify;">More to come on the next days&#8230;</p>
<p style="text-align: justify;"><a href="http://www.techonthenet.com/oracle/index.php">http://www.techonthenet.com/oracle/index.php</a></p>
<h3 style="text-align: justify;">Listing all the schemas, schema owners, database &amp; instance name</h3>
<p style="text-align: justify;">
<div class="codecolorer-container text geshi" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">with get_schemas as(<br />
select distinct owner<br />
from dba_objects<br />
)<br />
select name db_name, instance_name, owner<br />
from v$instance, v$database, get_schemas;</div></td></tr></tbody></table></div></p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/24/aiding-the-suffering-new-oracle-dba/" target="_blank"><img src="http://www.myrotarycar.com/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/24/aiding-the-suffering-new-oracle-dba/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://www.myrotarycar.com/blog/index.php/2010/02/24/aiding-the-suffering-new-oracle-dba/&title=Aiding the suffering new Oracle DBA" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.myrotarycar.com/blog/index.php/feed/rss/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://www.myrotarycar.com/blog/index.php/2010/02/24/aiding-the-suffering-new-oracle-dba/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://www.myrotarycar.com/blog/index.php/2010/02/24/aiding-the-suffering-new-oracle-dba/&title=Aiding the suffering new Oracle DBA" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://www.myrotarycar.com/blog/index.php/2010/02/24/aiding-the-suffering-new-oracle-dba/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://www.myrotarycar.com/blog/index.php/2010/02/24/aiding-the-suffering-new-oracle-dba/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a tabular view of space used by all database tables</title>
		<link>http://www.myrotarycar.com/blog/index.php/2010/02/18/creating-a-tabular-view-of-space-used-by-all-database-tables/</link>
		<comments>http://www.myrotarycar.com/blog/index.php/2010/02/18/creating-a-tabular-view-of-space-used-by-all-database-tables/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 06:12:08 +0000</pubDate>
		<dc:creator>Miguel Pereira</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[sql 2000]]></category>
		<category><![CDATA[sql 2005]]></category>
		<category><![CDATA[sql 2008]]></category>

		<guid isPermaLink="false">http://www.myrotarycar.com/blog/?p=793</guid>
		<description><![CDATA[I&#8217;ve been asked all too often to forecast database storage growth over time. The cookie-cutter way to do it is tedious: monitor data file growth blindly over a period of time and derive gross growth from it. I, instead, prefer a more detailed approach which allows me to look not only at the overall space [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I&#8217;ve been asked all too often to forecast database storage growth over time. The cookie-cutter way to do it is tedious: monitor data file growth blindly over a period of time and derive gross growth from it. I, instead, prefer a more detailed approach which allows me to look not only at the overall space footprint of my database, but also at the space being used on a per-row basis, space used by indexes, and slack that might be pre-allocated and actually saved. I dabbed on using [sp_spaceused], which if I am not mistaken is available from SQL 2000 forward. But I wanted something a little more &#8216;hands-free&#8217;, so I came up with the following implementation which creates a temporary table that can easily be turned into a permanent table instead. This small CURSOR-based script can easily be modified to log table space utilization over time and allow for a far more educated &#8216;guess&#8217; on how much more drive space your application will need over time. So, here it is, another one of my handy-dandy SQL scripts:</p>
<div class="codecolorer-container text geshi" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:450px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">CREATE TABLE #tblSpace (name varchar(50),numRows int,txtReserved varchar(50),txtData varchar(50),txtIndexSize varchar(50),txtUnused varchar(50)) <br />
<br />
DECLARE @SQL AS VARCHAR(500)<br />
DECLARE @tablename sysname<br />
DECLARE tables_cursor CURSOR <br />
FOR <br />
&nbsp;<br />
SELECT '['+CONVERT(varchar(30),Name)+']' AS TableName &nbsp;<br />
FROM sysobjects WITH (NOLOCK) <br />
WHERE Type = 'U' &nbsp;<br />
ORDER BY TableName <br />
&nbsp;<br />
OPEN tables_cursor <br />
&nbsp;<br />
FETCH NEXT FROM tables_cursor INTO @tablename <br />
WHILE (@@FETCH_STATUS &lt;&gt; -1) <br />
BEGIN <br />
&nbsp; &nbsp; SET @SQL = 'INSERT INTO #tblSpace (name,numRows,txtReserved,txtData,txtIndexSize,txtUnused) EXEC sp_spaceused ' + @tablename<br />
&nbsp; &nbsp; EXEC (@SQL)<br />
&nbsp; &nbsp; FETCH NEXT FROM tables_cursor INTO @tablename <br />
END <br />
&nbsp; &nbsp; &nbsp; <br />
CLOSE tables_cursor <br />
DEALLOCATE tables_cursor<br />
<br />
SELECT* FROM #tblSpace ORDER BY name<br />
DROP TABLE #tblSpace</div></td></tr></tbody></table></div>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/18/creating-a-tabular-view-of-space-used-by-all-database-tables/" target="_blank"><img src="http://www.myrotarycar.com/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/18/creating-a-tabular-view-of-space-used-by-all-database-tables/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://www.myrotarycar.com/blog/index.php/2010/02/18/creating-a-tabular-view-of-space-used-by-all-database-tables/&title=Creating a tabular view of space used by all database tables" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.myrotarycar.com/blog/index.php/feed/rss/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://www.myrotarycar.com/blog/index.php/2010/02/18/creating-a-tabular-view-of-space-used-by-all-database-tables/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://www.myrotarycar.com/blog/index.php/2010/02/18/creating-a-tabular-view-of-space-used-by-all-database-tables/&title=Creating a tabular view of space used by all database tables" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://www.myrotarycar.com/blog/index.php/2010/02/18/creating-a-tabular-view-of-space-used-by-all-database-tables/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://www.myrotarycar.com/blog/index.php/2010/02/18/creating-a-tabular-view-of-space-used-by-all-database-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Querying Database Role Memberships &amp; Members on SQL 2005 (III)</title>
		<link>http://www.myrotarycar.com/blog/index.php/2010/02/17/querying-database-role-memberships-members-on-sql-2005-iii/</link>
		<comments>http://www.myrotarycar.com/blog/index.php/2010/02/17/querying-database-role-memberships-members-on-sql-2005-iii/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 05:57:19 +0000</pubDate>
		<dc:creator>Miguel Pereira</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[sql 2005]]></category>
		<category><![CDATA[sql 2008]]></category>
		<category><![CDATA[sql server security]]></category>

		<guid isPermaLink="false">http://www.myrotarycar.com/blog/?p=789</guid>
		<description><![CDATA[It&#8217;s time to put all the pieces together and create a simple way to take a look at all the memberships &#38; roles which exist across all our databases. Like I mentioned before, this might be very useful whenever an internal audit comes through and we are asked to produce a report: who, what, where [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">It&#8217;s time to put all the pieces together and create a simple way to take a look at all the memberships &amp; roles which exist across all our databases. Like I mentioned before, this might be very useful whenever an internal audit comes through and we are asked to produce a report: who, what, where &amp; when (just &#8216;Ws&#8217; here, no &#8216;How&#8217;).</p>
<ul style="text-align: justify;">
<li>Who has access?</li>
<li>What access level &#8216;who&#8217; has to our databases?</li>
<li>Where does &#8216;Who&#8217; has a &#8216;What&#8217; access?</li>
<li>When did &#8216;Who&#8217; gain &#8216;What&#8217; access to our databases?</li>
</ul>
<p style="text-align: justify;">Makes sense? <img src='http://www.myrotarycar.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: justify;">Let&#8217;s cut to the chase. Here is the script. Go ahead, execute it on your test server and see if you like it, change it, sell it, I don&#8217;t care. Just let me know if you find it useful or have any comments.</p>
<div class="codecolorer-container text geshi" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:450px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">CREATE TABLE #DBRolesAndMembers (<br />
&nbsp; &nbsp; dbname VARCHAR(50),<br />
&nbsp; &nbsp; role_principal_id INT,<br />
&nbsp; &nbsp; member_principal_id INT,<br />
&nbsp; &nbsp; role_type_desc VARCHAR(50),<br />
&nbsp; &nbsp; role_name VARCHAR(50),<br />
&nbsp; &nbsp; member_name VARCHAR(50),<br />
&nbsp; &nbsp; create_date DATETIME,<br />
&nbsp; &nbsp; modify_date DATETIME<br />
&nbsp; &nbsp; )<br />
GO<br />
<br />
DECLARE @DBNAME AS VARCHAR(50)<br />
DECLARE MyCursor CURSOR<br />
&nbsp; &nbsp; FOR SELECT [name] FROM sys.databases WHERE state = 0<br />
OPEN MyCursor<br />
<br />
FETCH NEXT FROM MyCursor INTO @DBNAME<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
DECLARE @SQL as varchar(max)<br />
set @sql = '<br />
&nbsp; &nbsp; INSERT INTO #DBRolesAndMembers<br />
&nbsp; &nbsp; SELECT<br />
&nbsp; &nbsp; &nbsp; &nbsp; '''+@DBNAME+''' as ''dbname'',<br />
&nbsp; &nbsp; &nbsp; &nbsp; drm.role_principal_id,<br />
&nbsp; &nbsp; &nbsp; &nbsp; drm.member_principal_id,<br />
&nbsp; &nbsp; &nbsp; &nbsp; dp.name as ''role_name'',<br />
&nbsp; &nbsp; &nbsp; &nbsp; dp.type_desc as ''role_type_desc'',<br />
&nbsp; &nbsp; &nbsp; &nbsp; dpu.name as ''member_name'',<br />
&nbsp; &nbsp; &nbsp; &nbsp; dpu.create_date as ''member_create_date'',<br />
&nbsp; &nbsp; &nbsp; &nbsp; dpu.modify_date as ''member_modify_date''<br />
&nbsp; &nbsp; FROM <br />
&nbsp; &nbsp; &nbsp; &nbsp; '+@DBNAME+'.sys.database_role_members as drm<br />
&nbsp; &nbsp; RIGHT JOIN '+@DBNAME+'.sys.database_principals as dp<br />
&nbsp; &nbsp; &nbsp; &nbsp; ON dp.principal_id = drm.role_principal_id<br />
&nbsp; &nbsp; RIGHT JOIN '+@DBNAME+'.sys.database_principals as dpu<br />
&nbsp; &nbsp; &nbsp; &nbsp; ON dpu.principal_id = drm.member_principal_id<br />
&nbsp; &nbsp; WHERE <br />
&nbsp; &nbsp; &nbsp; &nbsp; drm.role_principal_id IS NOT NULL<br />
&nbsp; &nbsp; &nbsp; &nbsp; AND drm.member_principal_id IS NOT NULL'<br />
exec (@sql)<br />
<br />
FETCH NEXT FROM MyCursor INTO @DBNAME<br />
<br />
END<br />
<br />
CLOSE MyCursor<br />
DEALLOCATE MyCursor<br />
SELECT * FROM #DBRolesAndMembers<br />
drop table #DBRolesAndMembers</div></td></tr></tbody></table></div>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/17/querying-database-role-memberships-members-on-sql-2005-iii/" target="_blank"><img src="http://www.myrotarycar.com/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/17/querying-database-role-memberships-members-on-sql-2005-iii/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://www.myrotarycar.com/blog/index.php/2010/02/17/querying-database-role-memberships-members-on-sql-2005-iii/&title=Querying Database Role Memberships &#038; Members on SQL 2005 (III)" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.myrotarycar.com/blog/index.php/feed/rss/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://www.myrotarycar.com/blog/index.php/2010/02/17/querying-database-role-memberships-members-on-sql-2005-iii/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://www.myrotarycar.com/blog/index.php/2010/02/17/querying-database-role-memberships-members-on-sql-2005-iii/&title=Querying Database Role Memberships &#038; Members on SQL 2005 (III)" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://www.myrotarycar.com/blog/index.php/2010/02/17/querying-database-role-memberships-members-on-sql-2005-iii/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://www.myrotarycar.com/blog/index.php/2010/02/17/querying-database-role-memberships-members-on-sql-2005-iii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Querying Database Role Memberships &amp; Members on SQL 2005 (II)</title>
		<link>http://www.myrotarycar.com/blog/index.php/2010/02/05/querying-database-role-memberships-members-on-sql-2005-ii/</link>
		<comments>http://www.myrotarycar.com/blog/index.php/2010/02/05/querying-database-role-memberships-members-on-sql-2005-ii/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 22:07:58 +0000</pubDate>
		<dc:creator>Miguel Pereira</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[sql 2005]]></category>
		<category><![CDATA[sql 2008]]></category>
		<category><![CDATA[sql server security]]></category>

		<guid isPermaLink="false">http://www.myrotarycar.com/blog/?p=780</guid>
		<description><![CDATA[On our previous article we briefly touched on database roles and what they are, but more importantly, we started to talk about database principals. A database principal is essentially any entity or object that can request SQL Server resources. So what entities are grouped under the principal &#8216;moniker&#8217;? Anythig from database roles downright to database [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">On our previous article we briefly touched on database roles and what they are, but more importantly, we started to talk about database principals. A database principal is essentially any entity or object that can request SQL Server resources. So what entities are grouped under the principal &#8216;moniker&#8217;? Anythig from database roles downright to database users.</p>
<p style="text-align: justify;">For instance, if we take a look at the list of principals on a [master] database, we might see a listing like this. And if we look under [name] we see that the first value corresponds to [public]; [public] is a database_level role -there is also a certificate mapped user. But why bag roles &amp; users together, if a user can be a member of one or more roles? Because resources can be controlled at database user and role levels alike, both offering varying grades of granularity.</p>
<div class="mceTemp" style="text-align: justify;">
<dl id="attachment_781" class="wp-caption alignnone" style="width: 985px;">
<dt class="wp-caption-dt"><a href="http://www.myrotarycar.com/blog/wp-content/uploads/2010/02/sys.database_principals.png"><img class="size-full wp-image-781 " title="sys.database_principals" src="http://www.myrotarycar.com/blog/wp-content/uploads/2010/02/sys.database_principals.png" alt="sys.database_principals" width="975" height="342" /></a></dt>
<dd class="wp-caption-dd">sys.database_principals</dd>
</dl>
</div>
<p style="text-align: justify;">The column definitions offered on the previous article should be rather self explanatory now that you can see actual data. Go ahead, query against one of your database&#8217;s sys.database_principals admin view and then compare it to what you see through SQL Server Management Studio for the same database.</p>
<p style="text-align: justify;">Now, the next step in our quest is to figure out what kind of memberships exist for our principal / users -which groups do users belong to? Pretty easy! There is obviously another management view which exposes that information (think of it this way from here on: anything that&#8217;s done through SSMS, can be replicated by transact-sql means). In our case, principal-users and role relations are exposed through: sys.database_role_members.</p>
<p style="text-align: justify;">
<div class="codecolorer-container text geshi" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SELECT * FROM sys.database_role_members</div></td></tr></tbody></table></div>
</p>
<p style="text-align: justify;">This view will expose the principal_id of the role matched against the principal_id of a user or other entity belonging to a role. And we will see how to exploit this very easily on the next article -I am tired &amp; cranky right now.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/05/querying-database-role-memberships-members-on-sql-2005-ii/" target="_blank"><img src="http://www.myrotarycar.com/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/05/querying-database-role-memberships-members-on-sql-2005-ii/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://www.myrotarycar.com/blog/index.php/2010/02/05/querying-database-role-memberships-members-on-sql-2005-ii/&title=Querying Database Role Memberships &#038; Members on SQL 2005 (II)" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.myrotarycar.com/blog/index.php/feed/rss/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://www.myrotarycar.com/blog/index.php/2010/02/05/querying-database-role-memberships-members-on-sql-2005-ii/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://www.myrotarycar.com/blog/index.php/2010/02/05/querying-database-role-memberships-members-on-sql-2005-ii/&title=Querying Database Role Memberships &#038; Members on SQL 2005 (II)" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://www.myrotarycar.com/blog/index.php/2010/02/05/querying-database-role-memberships-members-on-sql-2005-ii/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://www.myrotarycar.com/blog/index.php/2010/02/05/querying-database-role-memberships-members-on-sql-2005-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Querying Database Role Memberships &amp; Members on SQL 2005</title>
		<link>http://www.myrotarycar.com/blog/index.php/2010/02/04/querying-database-role-memberships-members-on-sql-2005/</link>
		<comments>http://www.myrotarycar.com/blog/index.php/2010/02/04/querying-database-role-memberships-members-on-sql-2005/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 22:44:19 +0000</pubDate>
		<dc:creator>Miguel Pereira</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[sql 2005]]></category>
		<category><![CDATA[sql 2008]]></category>
		<category><![CDATA[sql server security]]></category>

		<guid isPermaLink="false">http://www.myrotarycar.com/blog/?p=774</guid>
		<description><![CDATA[A question was raised not long ago on one of the boards I frequently visit, by one member who was trying to generate an report for his management team to audit database level roles &#38; memberships -basically, who could do what and where?
The platform in question was Microsoft SQL Server 2005, and the key requirement [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">A question was raised not long ago on one of the boards I frequently visit, by one member who was trying to generate an report for his management team to audit database level roles &amp; memberships -basically, who could do what and where?</p>
<p style="text-align: justify;">The platform in question was Microsoft SQL Server 2005, and the key requirement was to be able to retrieve the same basic information that can be accessed via SQL Server Management Studio. So I set off to take a peek at the management views available in SQL 2005, and shortly after found what I was looking for.</p>
<p style="text-align: justify;">At the database level, there are 2 basic objects that are extremely useful when it comes to roles &amp; memberships. These are:</p>
<ul style="text-align: justify;">
<li>sys.database_role_members - Returns one row for each member of each database role.</li>
<li>sys.database_principals &#8211; Returns a row for each principal in a database.</li>
</ul>
<p style="text-align: justify;">At this point, I think its worth reviewing some concepts regarding SQL security related objects to make sure we are better prepared to absorb what we will be doing.</p>
<h3 style="text-align: justify;">What is a Database Role?</h3>
<p style="text-align: justify;"><em>Fixed database roles are defined at the database level and exist in each database. Members of the db_owner and db_securityadmin database roles can manage fixed database role membership; however, only members of the db_owner database role can add members to the db_owner fixed database role.</em></p>
<p style="text-align: justify;"><em>The fixed database roles are the following:</em></p>
<ul style="text-align: justify;">
<li><em>db_accessadmin</em></li>
<li><em>db_backupoperator</em></li>
<li><em>db_datareader</em></li>
<li><em>db_datawriter</em></li>
<li><em>db_ddladmin</em></li>
<li><em>db_denydatareader</em></li>
<li><em>db_denydatawriter</em></li>
<li><em>db_owner</em></li>
<li><em>db_securityadmin</em></li>
</ul>
<p style="text-align: justify;"><em>Every database user belongs to the public database role. When a user has not been granted or denied specific permissions on a securable, the user inherits the permissions granted to public on that securable.</em></p>
<p style="text-align: justify;">Also, remember that database roles can be created using CREATE ROLE role_name and members assigned and removed from them. This is, for the time being, outside of the scope and purpose of this article.</p>
<h3 style="text-align: justify;">What are Database Principals?</h3>
<p style="text-align: justify;">Principals are entities that can request SQL Server resources. Like other components of the SQL Server authorization model, principals can be arranged in a hierarchy. The scope of influence of a principal depends on the scope of the definition of the principal: Windows, server, database; and whether the principal is indivisible or a collection. A Windows Login is an example of an indivisible principal, and a Windows Group is an example of a principal that is a collection. Every principal has a security identifier (SID).</p>
<p style="text-align: justify;">A <strong>database user is a principal at the database level</strong>. Every database user is a member of the public role.</p>
<p style="text-align: justify;">So, now that we have a textbook -literally lifted from BOL- definition of what are database roles &amp; principals, let&#8217;s inspect the data we get from our two management views.</p>
<h3 style="text-align: justify;">Querying sys.database_principals</h3>
<p style="text-align: justify;">Let&#8217;s run the following snippet on any database, for arguments sake, let&#8217;s do so on our [master] database of any database instance we might have handy.</p>
<div class="codecolorer-container text geshi" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SELECT * FROM sys.database_principals</div></td></tr></tbody></table></div>
<p style="text-align: justify;">Our dataset will contain a listing of the following columns:</p>
<ul>
<li>name &#8211; data type: sysname
<ul>
<li>Name of principal, unique within the database.</li>
</ul>
</li>
<li>principal_id &#8211; data type: int
<ul>
<li>ID of principal, unique within the database.</li>
</ul>
</li>
<li>type &#8211; data type: char(1)
<ul>
<li>Principal type: S = SQL user U = Windows user G = Windows group A = Application role R = Database role C = User mapped to a certificate K = User mapped to an asymmetric key</li>
</ul>
</li>
<li>type_desc &#8211; data type: nvarchar(60)
<ul>
<li>Description of principal type: SQL_USER WINDOWS_USER WINDOWS_GROUP APPLICATION_ROLE DATABASE_ROLE CERTIFICATE_MAPPED_USER ASYMMETRIC_KEY_MAPPED_USER</li>
</ul>
</li>
<li>default_schema_name &#8211; data type: sysname
<ul>
<li>Name to be used when SQL name does not specify schema. Null for principals not of type S, U, or A.</li>
</ul>
</li>
<li>create_date &#8211; data type: datetime
<ul>
<li>Time at which the principal was created.</li>
</ul>
</li>
<li>modify_date &#8211; data type: datetime
<ul>
<li>Time at which the principal was last modified.</li>
</ul>
</li>
<li>owning_principal_id &#8211; data type: int
<ul>
<li>ID of the principal that owns this principal. All principals except Database Roles must be owned by dbo.</li>
</ul>
</li>
<li>sid &#8211; data type: varbinary(85)
<ul>
<li>SID (Security Identifier) if the principal is defined external to the database (type S, U, and G). Otherwise, NULL.</li>
</ul>
</li>
<li>is_fixed_role &#8211; data type: bit
<ul>
<li>If 1, then this row represents an entry for one of the fixed database roles: db_owner, db_accessadmin, db_datareader, db_datawriter, db_ddladmin, db_securityadmin, db_backupoperator, db_denydatareader, db_denydatawriter.</li>
</ul>
</li>
</ul>
<p>Let&#8217;s review the key elements on the next article&#8230;</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/04/querying-database-role-memberships-members-on-sql-2005/" target="_blank"><img src="http://www.myrotarycar.com/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/04/querying-database-role-memberships-members-on-sql-2005/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://www.myrotarycar.com/blog/index.php/2010/02/04/querying-database-role-memberships-members-on-sql-2005/&title=Querying Database Role Memberships &#038; Members on SQL 2005" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.myrotarycar.com/blog/index.php/feed/rss/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://www.myrotarycar.com/blog/index.php/2010/02/04/querying-database-role-memberships-members-on-sql-2005/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://www.myrotarycar.com/blog/index.php/2010/02/04/querying-database-role-memberships-members-on-sql-2005/&title=Querying Database Role Memberships &#038; Members on SQL 2005" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://www.myrotarycar.com/blog/index.php/2010/02/04/querying-database-role-memberships-members-on-sql-2005/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://www.myrotarycar.com/blog/index.php/2010/02/04/querying-database-role-memberships-members-on-sql-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determine the port number of a SQL instance through SQL Query</title>
		<link>http://www.myrotarycar.com/blog/index.php/2010/02/01/determine-the-port-number-of-a-sql-instance-through-sql-query/</link>
		<comments>http://www.myrotarycar.com/blog/index.php/2010/02/01/determine-the-port-number-of-a-sql-instance-through-sql-query/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 20:38:08 +0000</pubDate>
		<dc:creator>Miguel Pereira</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[microsoft sql server 2005]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tsql]]></category>

		<guid isPermaLink="false">http://www.myrotarycar.com/blog/?p=765</guid>
		<description><![CDATA[This little query can be very handy sometimes.
1234567891011121314DECLARE @INSTANCENAME AS VARCHAR(20)
DECLARE @KeyString as VARCHAR(500)
SELECT @INSTANCENAME = RIGHT(@@SERVERNAME,LEN(@@SERVERNAME)-CHARINDEX('\',@@SERVERNAME))

SET @keystring = 'SOFTWARE\Microsoft\Microsoft SQL Server\' + @INSTANCENAME + '\MSSQLServer\SuperSocketNetLib\Tcp'

DECLARE @port varchar(5)

EXEC xp_regread @rootkey='HKEY_LOCAL_MACHINE',
@key=@keystring,
@value_name='TcpPort',
@value=@port OUTPUT

PRINT @port + '/' + @instancename
Share on Facebook
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				&#160;&#160;&#160;&#160;
				
				

                
		
				]]></description>
			<content:encoded><![CDATA[<p>This little query can be very handy sometimes.</p>
<div class="codecolorer-container text geshi" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DECLARE @INSTANCENAME AS VARCHAR(20)<br />
DECLARE @KeyString as VARCHAR(500)<br />
SELECT @INSTANCENAME = RIGHT(@@SERVERNAME,LEN(@@SERVERNAME)-CHARINDEX('\',@@SERVERNAME))<br />
<br />
SET @keystring = 'SOFTWARE\Microsoft\Microsoft SQL Server\' + @INSTANCENAME + '\MSSQLServer\SuperSocketNetLib\Tcp'<br />
<br />
DECLARE @port varchar(5)<br />
<br />
EXEC xp_regread @rootkey='HKEY_LOCAL_MACHINE',<br />
@key=@keystring,<br />
@value_name='TcpPort',<br />
@value=@port OUTPUT<br />
<br />
PRINT @port + '/' + @instancename</div></td></tr></tbody></table></div>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/01/determine-the-port-number-of-a-sql-instance-through-sql-query/" target="_blank"><img src="http://www.myrotarycar.com/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/02/01/determine-the-port-number-of-a-sql-instance-through-sql-query/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://www.myrotarycar.com/blog/index.php/2010/02/01/determine-the-port-number-of-a-sql-instance-through-sql-query/&title=Determine the port number of a SQL instance through SQL Query" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.myrotarycar.com/blog/index.php/feed/rss/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://www.myrotarycar.com/blog/index.php/2010/02/01/determine-the-port-number-of-a-sql-instance-through-sql-query/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://www.myrotarycar.com/blog/index.php/2010/02/01/determine-the-port-number-of-a-sql-instance-through-sql-query/&title=Determine the port number of a SQL instance through SQL Query" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://www.myrotarycar.com/blog/index.php/2010/02/01/determine-the-port-number-of-a-sql-instance-through-sql-query/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://www.myrotarycar.com/blog/index.php/2010/02/01/determine-the-port-number-of-a-sql-instance-through-sql-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handy SQL Script to KILL PIDs for specific databases</title>
		<link>http://www.myrotarycar.com/blog/index.php/2010/01/26/handy-sql-script-to-kill-pids-for-specific-databases/</link>
		<comments>http://www.myrotarycar.com/blog/index.php/2010/01/26/handy-sql-script-to-kill-pids-for-specific-databases/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 22:55:15 +0000</pubDate>
		<dc:creator>Miguel Pereira</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.myrotarycar.com/blog/?p=760</guid>
		<description><![CDATA[This little script&#8217;s helped me numerous times when refreshing environments manually from backups and had to ensure there were no left-over connections left which would&#8217;ve made the restores fail. Without further a due:
1234567891011121314151617181920212223242526DECLARE @dbspid AS int
DECLARE @killcommand AS varchar&#40;50&#41;
DECLARE ConnectionKiller CURSOR FOR
SELECT sysproc.spid FROM sysprocesses AS sysproc
INNER JOIN sysdatabases AS sysdb ON
sysdb.dbid = sysproc.dbid
WHERE sysdb.NAME IN [...]]]></description>
			<content:encoded><![CDATA[<p>This little script&#8217;s helped me numerous times when refreshing environments manually from backups and had to ensure there were no left-over connections left which would&#8217;ve made the restores fail. Without further a due:</p>
<div class="codecolorer-container sql geshi" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:450px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DECLARE @dbspid <span style="color: #993333; font-weight: bold;">AS</span> int<br />
DECLARE @killcommand <span style="color: #993333; font-weight: bold;">AS</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><br />
DECLARE ConnectionKiller CURSOR <span style="color: #993333; font-weight: bold;">FOR</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> sysproc<span style="color: #66cc66;">.</span>spid <span style="color: #993333; font-weight: bold;">FROM</span> sysprocesses <span style="color: #993333; font-weight: bold;">AS</span> sysproc<br />
<span style="color: #993333; font-weight: bold;">INNER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> sysdatabases <span style="color: #993333; font-weight: bold;">AS</span> sysdb <span style="color: #993333; font-weight: bold;">ON</span><br />
sysdb<span style="color: #66cc66;">.</span>dbid <span style="color: #66cc66;">=</span> sysproc<span style="color: #66cc66;">.</span>dbid<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> sysdb<span style="color: #66cc66;">.</span>NAME <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'[DBNAME]'</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">AND</span> sysproc<span style="color: #66cc66;">.</span>spid <span style="color: #66cc66;">&lt;&gt;</span> <span style="color: #cc66cc;">0</span><br />
<span style="color: #993333; font-weight: bold;">UNION</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> sysproc<span style="color: #66cc66;">.</span>blocked <span style="color: #993333; font-weight: bold;">FROM</span> sysprocesses <span style="color: #993333; font-weight: bold;">AS</span> sysproc<br />
<span style="color: #993333; font-weight: bold;">INNER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> sysdatabases <span style="color: #993333; font-weight: bold;">AS</span> sysdb <span style="color: #993333; font-weight: bold;">ON</span><br />
sysdb<span style="color: #66cc66;">.</span>dbid <span style="color: #66cc66;">=</span> sysproc<span style="color: #66cc66;">.</span>dbid<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> sysdb<span style="color: #66cc66;">.</span>NAME <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'[DBNAME]'</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">AND</span> sysproc<span style="color: #66cc66;">.</span>blocked<span style="color: #66cc66;">&lt;&gt;</span><span style="color: #cc66cc;">0</span><br />
<br />
OPEN ConnectionKiller<br />
<br />
FETCH NEXT <span style="color: #993333; font-weight: bold;">FROM</span> ConnectionKiller <span style="color: #993333; font-weight: bold;">INTO</span> @dbspid<br />
WHILE @@FETCH_STATUS <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span><br />
BEGIN<br />
<span style="color: #993333; font-weight: bold;">SET</span> @killcommand <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'KILL '</span><span style="color: #66cc66;">+</span>CAST<span style="color: #66cc66;">&#40;</span>@dbspid <span style="color: #993333; font-weight: bold;">AS</span> VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
EXEC <span style="color: #66cc66;">&#40;</span>@killcommand<span style="color: #66cc66;">&#41;</span><br />
FETCH NEXT <span style="color: #993333; font-weight: bold;">FROM</span> ConnectionKiller <span style="color: #993333; font-weight: bold;">INTO</span> @dbspid<br />
END<br />
CLOSE ConnectionKiller<br />
DEALLOCATE ConnectionKiller</div></td></tr></tbody></table></div>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/01/26/handy-sql-script-to-kill-pids-for-specific-databases/" target="_blank"><img src="http://www.myrotarycar.com/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/01/26/handy-sql-script-to-kill-pids-for-specific-databases/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://www.myrotarycar.com/blog/index.php/2010/01/26/handy-sql-script-to-kill-pids-for-specific-databases/&title=Handy SQL Script to KILL PIDs for specific databases" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.myrotarycar.com/blog/index.php/feed/rss/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://www.myrotarycar.com/blog/index.php/2010/01/26/handy-sql-script-to-kill-pids-for-specific-databases/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://www.myrotarycar.com/blog/index.php/2010/01/26/handy-sql-script-to-kill-pids-for-specific-databases/&title=Handy SQL Script to KILL PIDs for specific databases" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://www.myrotarycar.com/blog/index.php/2010/01/26/handy-sql-script-to-kill-pids-for-specific-databases/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://www.myrotarycar.com/blog/index.php/2010/01/26/handy-sql-script-to-kill-pids-for-specific-databases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transact SQL &#8211; JOINS 101</title>
		<link>http://www.myrotarycar.com/blog/index.php/2010/01/21/transact-sql-joins-101/</link>
		<comments>http://www.myrotarycar.com/blog/index.php/2010/01/21/transact-sql-joins-101/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 06:01:15 +0000</pubDate>
		<dc:creator>Miguel Pereira</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[joins]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.myrotarycar.com/blog/?p=753</guid>
		<description><![CDATA[I&#8217;ve seen quite a bit of confusion as to the purpose and application of the four basic JOIN operations available for transact SQL. Even I dread coming out of my main comfort zone (my beloved INNER JOIN) sometimes. Nonetheless, JOINS are one of the most essential building blocks to some of the more complex data [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I&#8217;ve seen quite a bit of confusion as to the purpose and application of the four basic JOIN operations available for transact SQL. Even I dread coming out of my main comfort zone (my beloved INNER JOIN) sometimes. Nonetheless, JOINS are one of the most essential building blocks to some of the more complex data manipulation operations that transact-SQL has to offer. Now, below is my pre-K attempt at documenting their use, in a simplistic and easy to understand manner. It is not perfect, and it is geared towards the Microsoft SQL interpretation of the ANSI SQL standards.</p>
<div id="attachment_772" class="wp-caption alignnone" style="width: 160px"><a href="http://www.myrotarycar.com/blog/wp-content/uploads/2010/01/VennForSQLJOINS.png"><img class="size-thumbnail wp-image-772 " title="Venn Diagram - SQL Joins Explained" src="http://www.myrotarycar.com/blog/wp-content/uploads/2010/01/VennForSQLJOINS-150x150.png" alt="Venn Diagram - SQL Joins Explained" width="150" height="150" /></a><p class="wp-caption-text">Venn Diagram - SQL Joins Explained</p></div>
<p style="text-align: justify;">
<div style="text-align: justify;">
<div class="codecolorer-container text geshi" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:450px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">CREATE TABLE #tmpSpanish (numNumber int,txtNumber varchar(20))<br />
INSERT INTO #tmpSpanish (numNumber,txtNumber) VALUES (1,'Uno')<br />
INSERT INTO #tmpSpanish (numNumber,txtNumber) VALUES (2,'Dos')<br />
INSERT INTO #tmpSpanish (numNumber,txtNumber) VALUES (3,'Tres')<br />
INSERT INTO #tmpSpanish (numNumber,txtNumber) VALUES (4,'Cuatro')<br />
INSERT INTO #tmpSpanish (numNumber,txtNumber) VALUES (5,'Cinco')<br />
INSERT INTO #tmpSpanish (numNumber,txtNumber) VALUES (6,'Seis')<br />
INSERT INTO #tmpSpanish (numNumber,txtNumber) VALUES (7,'Siete')<br />
<br />
CREATE TABLE #tmpEnglish (numNumber int,txtNumber varchar(20))<br />
INSERT INTO #tmpEnglish (numNumber,txtNumber) VALUES (4,'Four')<br />
INSERT INTO #tmpEnglish (numNumber,txtNumber) VALUES (5,'Five')<br />
INSERT INTO #tmpEnglish (numNumber,txtNumber) VALUES (6,'Six')<br />
INSERT INTO #tmpEnglish (numNumber,txtNumber) VALUES (7,'Seven')<br />
INSERT INTO #tmpEnglish (numNumber,txtNumber) VALUES (8,'Eight')<br />
INSERT INTO #tmpEnglish (numNumber,txtNumber) VALUES (9,'Nine')<br />
INSERT INTO #tmpEnglish (numNumber,txtNumber) VALUES (10,'Ten')<br />
INSERT INTO #tmpEnglish (numNumber,txtNumber) VALUES (11,'Eleven')<br />
INSERT INTO #tmpEnglish (numNumber,txtNumber) VALUES (12,'Twelve')<br />
INSERT INTO #tmpEnglish (numNumber,txtNumber) VALUES (13,'Thirteen')<br />
<br />
/*<br />
An INNER JOIN will kindly return all rows which satisfy the JOIN condition on both tables.<br />
Picture a Venn Diagram, with three areas: A, B &amp;amp; C. B contains all the overlapping elements<br />
from A &amp;amp; B. This is what an INNER JOIN will return.<br />
*/<br />
SELECT * FROM #tmpSpanish<br />
INNER JOIN #tmpEnglish<br />
ON #tmpSpanish.numNumber = #tmpEnglish.numNumber<br />
<br />
/*<br />
A LEFT JOIN will return all rows which exist in the left-most table:<br />
(LEFT) (RIGHT)<br />
ON #tmpSpanish.numNumber = #tmpEnglish.numNumber<br />
<br />
Plus, all the common elements to both tables. Picture a Venn Diagram,<br />
with three areas: A, B &amp;amp; C. B contains all the overlapping elements<br />
from A &amp;amp; C. This join, will return all the elements from A &amp;amp; all the<br />
elements from B.<br />
*/<br />
SELECT * FROM #tmpSpanish<br />
LEFT JOIN #tmpEnglish<br />
ON #tmpSpanish.numNumber = #tmpEnglish.numNumber<br />
<br />
/*<br />
A RIGHT JOIN will return all rows which exist in the right-most table:<br />
<br />
(LEFT) (RIGHT)<br />
ON #tmpSpanish.numNumber = #tmpEnglish.numNumber<br />
<br />
Plus, all the common elements to both tables. Picture a Venn Diagram,<br />
with three areas: A, B &amp;amp; C. B contains all the overlapping elements<br />
from A &amp;amp; C. This join, will return all the elements from C &amp;amp; all the<br />
elements from B.<br />
*/<br />
SELECT * FROM #tmpSpanish<br />
RIGHT JOIN #tmpEnglish<br />
ON #tmpSpanish.numNumber = #tmpEnglish.numNumber<br />
<br />
/*<br />
A FULL OUTER JOIN will return all rows which exist on both tables, left &amp;amp; right-most.<br />
<br />
(LEFT) (RIGHT)<br />
ON #tmpSpanish.numNumber = #tmpEnglish.numNumber<br />
<br />
Including all the common elements to both tables. Picture a Venn Diagram,<br />
with three areas: A, B &amp;amp; C. B contains all the overlapping elements<br />
from A &amp;amp; C. This join essentially returns all of the elements from A &amp;amp; C, including<br />
those common (B) to both.<br />
*/<br />
SELECT * FROM #tmpSpanish<br />
FULL OUTER JOIN #tmpEnglish<br />
ON #tmpSpanish.numNumber = #tmpEnglish.numNumber<br />
<br />
DROP TABLE #tmpSpanish<br />
DROP TABLE #tmpEnglish</div></td></tr></tbody></table></div>
</div>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/01/21/transact-sql-joins-101/" target="_blank"><img src="http://www.myrotarycar.com/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/01/21/transact-sql-joins-101/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://www.myrotarycar.com/blog/index.php/2010/01/21/transact-sql-joins-101/&title=Transact SQL &#8211; JOINS 101" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.myrotarycar.com/blog/index.php/feed/rss/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://www.myrotarycar.com/blog/index.php/2010/01/21/transact-sql-joins-101/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://www.myrotarycar.com/blog/index.php/2010/01/21/transact-sql-joins-101/&title=Transact SQL &#8211; JOINS 101" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://www.myrotarycar.com/blog/index.php/2010/01/21/transact-sql-joins-101/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://www.myrotarycar.com/blog/index.php/2010/01/21/transact-sql-joins-101/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle DBCA through XMING</title>
		<link>http://www.myrotarycar.com/blog/index.php/2010/01/15/oracle-dbca-through-xming/</link>
		<comments>http://www.myrotarycar.com/blog/index.php/2010/01/15/oracle-dbca-through-xming/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 18:41:04 +0000</pubDate>
		<dc:creator>Miguel Pereira</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[dbca]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[putty]]></category>
		<category><![CDATA[xming]]></category>

		<guid isPermaLink="false">http://www.myrotarycar.com/blog/?p=750</guid>
		<description><![CDATA[Someone remind me, why do I still bother? OK, hope this helps someone, some day out there stuck in the same boat I was not 5 minutes ago. I was trying to create a DB instance on an Oracle 10.2.0.4 deployment on RHEL 5.3 64-bit located on a remote server without an X11 environment. I [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Someone remind me, why do I still bother? OK, hope this helps someone, some day out there stuck in the same boat I was not 5 minutes ago. I was trying to create a DB instance on an Oracle 10.2.0.4 deployment on RHEL 5.3 64-bit located on a remote server without an X11 environment. I work from a Windows XP Pro workstation -most the times anyways- and had to use the combination of XMING &amp; Putty to get things going through DBCA.</p>
<p style="text-align: justify;">My entire goal was to crack open a third-party database template file (.dbt) for 10g, plug it into DBCA, tweak a few settings and get it over with as quickly as possible. After this part is done, I still have to figure out how to get two Oracle export files (.dmp) imported under their respective schemas. Suffice it to say, tonight won&#8217;t be fun.</p>
<p style="text-align: justify;">My problem &amp; the solution -which I hope will save you some time- was this: I was getting to the end of the DBCA wizard steps -STEP 12- and after clicking on finish for the second time, after reviewing the HTML version of my settings- DBCA was going nowhere&#8230;really&#8230;SLOW. I poked around the DBCA trace files (located under $ORACLE_HOME/cfgtools/dbca/trace.log) and all I could locate was an indication that the Finish button had been clicked</p>
<blockquote style="text-align: justify;"><p>[AWT-EventQueue-0] [21:25:9:949] [DBCAWizard.onFinish:1139] m_bFinishClicked:true</p></blockquote>
<p style="text-align: justify;">I went bananas for two hours over this, browsing through the pretty-much-all the time useless OTN forums, and some other random places. Until I stumbled across the easiest thing, which I had not tried: is the problem with DBCA or with the X-Server? I found a few hits of people who, like me, had tried to run DBCA (and OUI) over an X11 remote session and had failed misserably, only to discover that running the same thing locally on a GNOME of KDE session went by without a hitch. A little bit more diggin, twenty more attempts and then I noticed that my terminal sessions was reporting the following when I was kick starting DBCA:</p>
<blockquote style="text-align: justify;"><p>-sh-3.2$ dbca<br />
Warning: Cannot convert string &#8220;-b&amp;h-lucida-medium-r-normal-sans-*-140-*-*-p-*-iso8859-1&#8243; to type FontStruct</p></blockquote>
<p style="text-align: justify;">Of the twenty times I had run the install I thought nothing of it. Dismissed it as something trivial. Then, out of desperation, I went ahead: downloaded and installed the complete XMING fonts package from Sourceforge. Here I was, install attempt number 21 and guess what? SUCCESS!!!</p>
<p style="text-align: justify;">For reference, I&#8217;ve been using the following setup:</p>
<ul style="text-align: justify;">
<li>Putty 0.60</li>
<li style="text-align: justify;">Xming 6.9.0.31</li>
</ul>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/01/15/oracle-dbca-through-xming/" target="_blank"><img src="http://www.myrotarycar.com/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.myrotarycar.com/blog/index.php/2010/01/15/oracle-dbca-through-xming/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://www.myrotarycar.com/blog/index.php/2010/01/15/oracle-dbca-through-xming/&title=Oracle DBCA through XMING" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.myrotarycar.com/blog/index.php/feed/rss/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://www.myrotarycar.com/blog/index.php/2010/01/15/oracle-dbca-through-xming/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://www.myrotarycar.com/blog/index.php/2010/01/15/oracle-dbca-through-xming/&title=Oracle DBCA through XMING" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://www.myrotarycar.com/blog/index.php/2010/01/15/oracle-dbca-through-xming/" rel="nofollow">
				<img src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://www.myrotarycar.com/blog/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://www.myrotarycar.com/blog/index.php/2010/01/15/oracle-dbca-through-xming/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
