<?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>mikedopp.com &#187; SQL Change Owner Script</title>
	<atom:link href="http://mikedopp.com/index.php/tag/sql-change-owner-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikedopp.com</link>
	<description>Code Monkey by Day, Unix/Windows Administrator by Night, Social Media Chump 24/7</description>
	<lastBuildDate>Wed, 09 Jun 2010 07:37:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>SQL Owner Change Script</title>
		<link>http://mikedopp.com/index.php/2009/08/04/sql-owner-change-script/</link>
		<comments>http://mikedopp.com/index.php/2009/08/04/sql-owner-change-script/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 07:11:00 +0000</pubDate>
		<dc:creator>mikedopp</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SQL/Database]]></category>
		<category><![CDATA[SQL Change Owner Script]]></category>

		<guid isPermaLink="false">http://mikedopp.com/index.php/sql-owner-change-script/</guid>
		<description><![CDATA[sp_changeobjectowner [ @objname = ] &#8216;object&#8217; , [ @newowner = ] &#8216;owner&#8217; SELECT &#8216;EXEC sp_changeobjectowner &#8221;&#8217;+ SCHEMA_NAME(schema_id) + &#8216;.&#8217; + OBJECT_NAME(object_Id) + &#8221;&#8217;, &#8221;dbo&#8221;&#8217;FROM sys.tables In order to change the owner of an object in the current database, use the sp_changeobjectowner system stored procedure. The basic syntax is as follows: sp_changeobjectowner [ @objname = ] [...]]]></description>
			<content:encoded><![CDATA[<p>sp_changeobjectowner [ @objname = ] &#8216;object&#8217; , [ @newowner = ] &#8216;owner&#8217; </p>
<p>SELECT &#8216;EXEC sp_changeobjectowner &#8221;&#8217;+ SCHEMA_NAME(schema_id) + &#8216;.&#8217; + OBJECT_NAME(object_Id) + &#8221;&#8217;, &#8221;dbo&#8221;&#8217;FROM sys.tables </p>
<p>In order to change the owner of an object in the current database, use the sp_changeobjectowner system stored procedure. The basic syntax is as follows: </p>
<p>sp_changeobjectowner [ @objname = ] &#8216;object&#8217; , [ @newowner = ] &#8216;owner&#8217;   <br />In order to generate the Script to Change Owner of all Tables in a database, use this query </p>
<p>SELECT &#8216;EXEC sp_changeobjectowner &#8221;&#8217;+ SCHEMA_NAME(schema_id) + &#8216;.&#8217; + OBJECT_NAME(object_Id) + &#8221;&#8217;, &#8221;dbo&#8221;&#8217;FROM sys.tables   <br />Executing the query in SQL Server Management Studio generates the script required to change the owner of all tables in the database. I ran this query on the AdventureWorks database which generated the following output. Right Click on the output and Copy all the records </p>
<p>All you need to do now is paste the script generated and execute it in a query window to change the owner of all tables in the data. The generated script is as shown below: </p>
<p>EXEC sp_changeobjectowner &#8216;Production.ProductInventory&#8217;, &#8216;dbo&#8217;EXEC sp_changeobjectowner &#8216;Sales.SpecialOffer&#8217;, &#8216;dbo&#8217;EXEC sp_changeobjectowner &#8216;Person.Address&#8217;, &#8216;dbo&#8217;EXEC sp_changeobjectowner &#8216;Production.ProductListPriceHistory&#8217;, &#8216;dbo&#8217;EXEC sp_changeobjectowner &#8216;Person.AddressType&#8217;, &#8216;dbo&#8217;EXEC sp_changeobjectowner &#8216;Sales.SpecialOfferProduct&#8217;, &#8216;dbo&#8217;   <br />and so on……. </p>
<p>Rock ON!</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1804849c-fc7a-4b6c-8874-adb651aceebe" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/SQL+Change+Owner+Script" rel="tag">SQL Change Owner Script</a>,<a href="http://technorati.com/tags/Script+to+Change+SQL+database+Owner" rel="tag">Script to Change SQL database Owner</a></div>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:32ec733e-b549-4528-aa8b-fb131c2f6dcb" class="wlWriterEditableSmartContent">LiveJournal Tags: <a href="http://www.livejournal.com/interests.bml?int=SQL+Change+Owner+Script" rel="tag">SQL Change Owner Script</a>,<a href="http://www.livejournal.com/interests.bml?int=Script+to+Change+SQL+database+Owner" rel="tag">Script to Change SQL database Owner</a></div>
</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:2b287444-17b0-489a-a927-ca48857c37b4" class="wlWriterEditableSmartContent">Flickr Tags: <a href="http://flickr.com/photos/tags/SQL+Change+Owner+Script" rel="tag">SQL Change Owner Script</a>,<a href="http://flickr.com/photos/tags/Script+to+Change+SQL+database+Owner" rel="tag">Script to Change SQL database Owner</a></div>
</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:d9cb4175-6932-4c0a-a75a-751e999b292f" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/SQL+Change+Owner+Script" rel="tag">SQL Change Owner Script</a>,<a href="http://del.icio.us/popular/Script+to+Change+SQL+database+Owner" rel="tag">Script to Change SQL database Owner</a></div>
</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9011b89e-e86a-4b6a-8881-6c7786034e0d" class="wlWriterEditableSmartContent">IceRocket Tags: <a href="http://blogs.icerocket.com/search?q=SQL+Change+Owner+Script" rel="tag">SQL Change Owner Script</a>,<a href="http://blogs.icerocket.com/search?q=Script+to+Change+SQL+database+Owner" rel="tag">Script to Change SQL database Owner</a></div>
</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:85e787b9-5cb5-4d6b-b7e4-b8b15c24ae35" class="wlWriterEditableSmartContent">43 Things Tags: <a href="http://www.43things.com/tag/SQL+Change+Owner+Script" rel="tag">SQL Change Owner Script</a>,<a href="http://www.43things.com/tag/Script+to+Change+SQL+database+Owner" rel="tag">Script to Change SQL database Owner</a></div>
</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:afcfe202-5225-4a83-a02b-49b4f7c59a18" class="wlWriterEditableSmartContent">BuzzNet Tags: <a href="http://www.buzznet.com/tags/SQL+Change+Owner+Script" rel="tag">SQL Change Owner Script</a>,<a href="http://www.buzznet.com/tags/Script+to+Change+SQL+database+Owner" rel="tag">Script to Change SQL database Owner</a></div>
]]></content:encoded>
			<wfw:commentRss>http://mikedopp.com/index.php/2009/08/04/sql-owner-change-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
