<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tags 'metadata' and 'DAC'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=metadata,DAC&amp;orTags=0</link><description>Search results matching tags 'metadata' and 'DAC'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>sys.sp_hexadecimal : A Quasi-System Object?</title><link>http://sqlblog.com/blogs/aaron_bertrand/archive/2011/08/06/sys-sp-hexadecimal-a-quasi-system-object.aspx</link><pubDate>Sat, 06 Aug 2011 05:05:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:37544</guid><dc:creator>AaronBertrand</dc:creator><description>&lt;p&gt;In &lt;a href="http://support.microsoft.com/kb/918992" title="http://support.microsoft.com/kb/918992" target="_blank"&gt;KB #918992&lt;/a&gt; and &lt;a href="http://support.microsoft.com/kb/246133" title="http://support.microsoft.com/kb/246133" target="_blank"&gt;KB #246133&lt;/a&gt;&lt;span&gt;&lt;/span&gt;, which describe how to transfer logins between instances, Microsoft recommends creating a user procedure in master called sp_hexadecimal (with no schema prefix, tsk tsk). Since I know there have been a lot of people who have created this procedure in SQL Server 2008 R2 and Denali, in spite of the fact that the articles are intended only for prior versions, I suggest you call it something else. Why?&lt;/p&gt;

&lt;p&gt;A user on twitter (&lt;a href="http://twitter.com/SQLDetails" title="http://twitter.com/SQLDetails" target="_blank"&gt;@SQLDetails&lt;/a&gt;) asked on &lt;a href="http://twitter.com/#%21/search?q=%23sqlhelp" title="http://twitter.com/#!/search?q=%23sqlhelp" target="_blank"&gt;#sqlhelp&lt;/a&gt; why sp_helptext didn't work against his copy of sp_hexadecimal. Sure enough, sp_helptext does not work. I created the following procedure in master:&lt;/p&gt;

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;USE &lt;/font&gt;&lt;font color="black"&gt;[master]&lt;/font&gt;&lt;font color="gray"&gt;;&lt;br&gt;&lt;/font&gt;&lt;font color="black"&gt;&lt;/font&gt;&lt;font color="blue"&gt;GO&lt;br&gt;CREATE PROCEDURE &lt;/font&gt;&lt;font color="black"&gt;dbo.sp_hexadecimal&lt;/font&gt;&lt;font color="darkred"&gt;&lt;br&gt;&lt;/font&gt;&lt;font color="blue"&gt;AS&lt;br&gt;BEGIN&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SET NOCOUNT ON&lt;/font&gt;&lt;font color="gray"&gt;;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;PRINT &lt;/font&gt;&lt;font color="black"&gt;1&lt;/font&gt;&lt;font color="gray"&gt;;&lt;br&gt;&lt;/font&gt;&lt;font color="blue"&gt;END&lt;br&gt;&lt;/font&gt;&lt;font&gt;&lt;font color="blue"&gt;GO&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;


&lt;p&gt;Executing the procedure works fine, but any variation of sp_helptext (with or without specifying the proper schema prefix) did not:&lt;/p&gt;

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;EXEC &lt;/font&gt;&lt;font color="darkred"&gt;sp_helptext &lt;/font&gt;&lt;font color="red"&gt;'dbo.sp_hexadecimal'&lt;/font&gt;&lt;font color="gray"&gt;;&lt;/font&gt;&lt;br&gt;&lt;br&gt;&lt;font color="red"&gt;Msg 15197, Level 16, State 1, Procedure sp_helptext, Line 91&lt;br&gt;There is no text for object 'dbo.sp_hexadecimal'.&lt;/font&gt;
&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;


&lt;p&gt;OBJECT_DEFINITION() worked just fine, and gave me the text of the procedure no problem:&lt;/p&gt;


&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;SELECT &lt;/font&gt;&lt;font&gt;&lt;font color="magenta"&gt;OBJECT_DEFINITION&lt;/font&gt;&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="magenta"&gt;OBJECT_ID&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="red"&gt;'dbo.sp_hexadecimal'&lt;/font&gt;&lt;font color="gray"&gt;));&lt;/font&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;


&lt;p&gt;So what gives? I dug into sp_helptext to see where Msg 15197 was coming from. There were two spots, but the one in question makes It seem that sp_helptext (or some underlying engine logic) ignores or overrides the specified schema prefix.This error does not occur if I create a stored procedure called sp_hexadecimal under another schema, so it seems to be isolated to the dbo schema.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Making a copy of sp_helptext in the dbo schema led to the correct rendering of the source, just like OBJECT_DEFINITION() (this is what leads me to believe there is something deeper than sp_helptext itself that causes the problem). I filed a bug against sp_helptext, &lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/683234/sp-helptext-treats-non-system-objects-as-system-objects" title="http://connect.microsoft.com/SQLServer/feedback/details/683234/sp-helptext-treats-non-system-objects-as-system-objects" target="_blank"&gt;Connect #683234, sp_helptext treats non-system objects as system objects&lt;/a&gt;. But since &lt;a href="http://www.google.com/search?q=sp_helptext+aaronbertrand+site%3Aconnect.micosoft.com&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;aq=t&amp;amp;rls=org.mozilla:en-US:official&amp;amp;client=firefox-a#sclient=psy&amp;amp;hl=en&amp;amp;client=firefox-a&amp;amp;hs=DeF&amp;amp;rls=org.mozilla:en-US%3Aofficial&amp;amp;source=hp&amp;amp;q=sp_helptext+aaronbertrand+site:connect.microsoft.com&amp;amp;pbx=1&amp;amp;oq=sp_helptext+aaronbertrand+site:connect.microsoft.com&amp;amp;aq=f&amp;amp;aqi=&amp;amp;aql=&amp;amp;gs_sm=e&amp;amp;gs_upl=6213l6213l0l6320l1l1l0l0l0l0l0l0ll0l0&amp;amp;bav=on.2,or.r_gc.r_pw.r_cp.&amp;amp;fp=ef64ef23b5d1539e&amp;amp;biw=1360&amp;amp;bih=737" title="http://www.google.com/search?q=sp_helptext+aaronbertrand+site%3Aconnect.micosoft.com&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;aq=t&amp;amp;rls=org.mozilla:en-US:official&amp;amp;client=firefox-a#sclient=psy&amp;amp;hl=en&amp;amp;client=firefox-a&amp;amp;hs=DeF&amp;amp;rls=org.mozilla:en-US%3Aofficial&amp;amp;source=hp&amp;amp;q=sp_helptext+aaronbertrand+site:connect.microsoft.com&amp;amp;pbx=1&amp;amp;oq=sp_helptext+aaronbertrand+site:connect.microsoft.com&amp;amp;aq=f&amp;amp;aqi=&amp;amp;aql=&amp;amp;gs_sm=e&amp;amp;gs_upl=6213l6213l0l6320l1l1l0l0l0l0l0l0ll0l0&amp;amp;bav=on.2,or.r_gc.r_pw.r_cp.&amp;amp;fp=ef64ef23b5d1539e&amp;amp;biw=1360&amp;amp;bih=737" target="_blank"&gt;several of the bugs and suggestions I've filed involving this object&lt;/a&gt; have been closed as fixed or generated cricket sounds, I don't have a whole lot of faith it will be fixed. It's common knowledge that the sp_ system procedures are not going to be modified for new features (or any non-severe bugs).&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Long story short: this all happens because sp_hexadecimal is what I call a &lt;b&gt;quasi-system object&lt;/b&gt;.&lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;&lt;font size="4"&gt;Huh? What does that mean?&lt;/font&gt;&lt;/i&gt; &lt;/p&gt;

&lt;p&gt;Well, it took quite a bit of unraveling, but as it turns out, sp_hexadecimal is kind of a hidden system procedure. In the master database, you can't see any evidence of its existence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;SELECT&lt;br&gt;    &lt;/font&gt;&lt;font color="magenta"&gt;OBJECT_ID&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="red"&gt;'sys.sp_hexadecimal'&lt;/font&gt;&lt;font color="gray"&gt;),&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="magenta"&gt;OBJECT_ID&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="red"&gt;'dbo.sp_hexadecimal'&lt;/font&gt;&lt;font color="gray"&gt;),&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="magenta"&gt;OBJECT_ID&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="red"&gt;'sp_hexadecimal'&lt;/font&gt;&lt;font color="gray"&gt;);&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;font color="blue"&gt;SELECT &lt;/font&gt;&lt;font color="black"&gt;[object_id] &lt;/font&gt;&lt;font color="blue"&gt;&lt;br&gt;    FROM &lt;/font&gt;&lt;font color="green"&gt;sys&lt;/font&gt;&lt;font&gt;&lt;font color="black"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;font color="green"&gt;all_objects&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="blue"&gt;WHERE &lt;/font&gt;&lt;font color="black"&gt;name &lt;/font&gt;&lt;font&gt;&lt;font color="gray"&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color="gray"&gt; &lt;/font&gt;&lt;font color="red"&gt;'sp_hexadecimal'&lt;/font&gt;&lt;font color="gray"&gt;;&lt;/font&gt;&lt;br&gt;&lt;br&gt;------------ ------------ ------------ 
NULL &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NULL &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NULL &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br&gt;&lt;br&gt;------------ 
NULL&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;


&lt;p&gt;There is, however, a stored procedure called sys.sp_hexadecimal in the resource database, which of course isn't visible to you under normal circumstances.&lt;br&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;i&gt;You can get to the resource database of course using the DAC (that's a &lt;a href="http://msdn.microsoft.com/en-us/library/ms189595.aspx" title="http://msdn.microsoft.com/en-us/library/ms189595.aspx" target="_blank"&gt;Dedicated Administrator Connection&lt;/a&gt;, not the other DAC, a &lt;a href="http://msdn.microsoft.com/en-us/library/ee240739.aspx" title="http://msdn.microsoft.com/en-us/library/ee240739.aspx" target="_blank"&gt;Data-Tier Application&lt;/a&gt;, even though now in Denali they're trying to shift the name to &lt;a href="http://msdn.microsoft.com/en-us/library/ms189595%28v=SQL.110%29.aspx" title="http://msdn.microsoft.com/en-us/library/ms189595%28v=SQL.110%29.aspx" target="_blank"&gt;Diagnostic Connection for Database Administrators&lt;/a&gt; - so now it's a DCDA, I guess). But I like &lt;a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/08/22/peeking-under-the-hood-what-bits-have-changed-in-sql-server-2008-r2.aspx" title="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/08/22/peeking-under-the-hood-what-bits-have-changed-in-sql-server-2008-r2.aspx" target="_blank"&gt;this old trick&lt;/a&gt; of attaching a copy of the resource database as another name. This way I don't have to remember to connect via DAC, be local on the server, etc. when I feel like sniffing around.&lt;br&gt;&lt;/i&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I loaded up a copy of the resource database, and sure enough, I found the object. But from there, the trail runs cold pretty quickly. There is a row in sys.all_sql_modules, but the definition is NULL, and OBJECT_DEFINITION() comes back empty as well:&lt;br&gt;&lt;/p&gt;


&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;SELECT&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;o.[object_id]&lt;/font&gt;&lt;font color="gray"&gt;,&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;[schema]&lt;/font&gt;&lt;font color="black"&gt; &lt;/font&gt;&lt;font&gt;&lt;font color="gray"&gt;  =&lt;/font&gt;&lt;/font&gt;&lt;font color="gray"&gt; &lt;/font&gt;&lt;font&gt;&lt;font color="magenta"&gt;SCHEMA_NAME&lt;/font&gt;&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="black"&gt;o.[schema_id]&lt;/font&gt;&lt;font color="gray"&gt;),&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;o.name&lt;/font&gt;&lt;font color="gray"&gt;,&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;module_def&lt;/font&gt;&lt;font color="black"&gt; &lt;/font&gt;&lt;font&gt;&lt;font color="gray"&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color="gray"&gt; &lt;/font&gt;&lt;font color="blue"&gt;&lt;/font&gt;&lt;font color="black"&gt;m.[definition]&lt;/font&gt;&lt;font color="gray"&gt;,&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;obj_def&lt;/font&gt;&lt;font color="black"&gt; &lt;/font&gt;&lt;font&gt;&lt;font color="gray"&gt;   =&lt;/font&gt;&lt;/font&gt;&lt;font color="gray"&gt; &lt;/font&gt;&lt;font&gt;&lt;font color="magenta"&gt;OBJECT_DEFINITION&lt;/font&gt;&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="black"&gt;o.[object_id]&lt;/font&gt;&lt;font color="gray"&gt;)&lt;br&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;FROM &lt;/font&gt;&lt;font color="green"&gt;sys&lt;/font&gt;&lt;font color="black"&gt;.&lt;/font&gt;&lt;font color="green"&gt;all_objects &lt;/font&gt;&lt;font color="blue"&gt;AS &lt;/font&gt;&lt;font color="black"&gt;o&lt;br&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;INNER JOIN &lt;/font&gt;&lt;font color="green"&gt;sys&lt;/font&gt;&lt;font color="black"&gt;.&lt;/font&gt;&lt;font color="green"&gt;all_sql_modules&lt;/font&gt;&lt;font color="black"&gt; &lt;/font&gt;&lt;font color="blue"&gt;AS &lt;/font&gt;&lt;font color="black"&gt;m&lt;br&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;ON &lt;/font&gt;&lt;font color="black"&gt;o.[object_id]&lt;/font&gt;&lt;font color="black"&gt; &lt;/font&gt;&lt;font&gt;&lt;font color="gray"&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color="gray"&gt; &lt;/font&gt;&lt;font color="blue"&gt;&lt;/font&gt;&lt;font color="black"&gt;m.[object_id]&lt;br&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;WHERE &lt;/font&gt;&lt;font color="black"&gt;o.name&lt;/font&gt;&lt;font color="black"&gt; &lt;/font&gt;&lt;font&gt;&lt;font color="gray"&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color="gray"&gt; &lt;/font&gt;&lt;font color="blue"&gt;&lt;/font&gt;&lt;font color="red"&gt;'sp_hexadecimal'&lt;/font&gt;&lt;font color="gray"&gt;;&lt;/font&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;


&lt;p&gt;&amp;nbsp;Results:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;img src="http://bertrandaaron.files.wordpress.com/2011/08/hex_results.png" border="0" height="65" width="588"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I also can't execute the stored procedure:&lt;/p&gt;


&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;EXEC &lt;/font&gt;&lt;font color="green"&gt;sys&lt;/font&gt;&lt;font color="black"&gt;.&lt;/font&gt;&lt;font color="darkred"&gt;sp_hexadecimal&lt;/font&gt;&lt;font color="gray"&gt;;&lt;/font&gt;&lt;br&gt;&lt;br&gt;&lt;font color="red"&gt;Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'sys.sp_hexadecimal'.&lt;/font&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;


&lt;p&gt;While I don't have a whole lot of concrete answers for you, the moral of the story is, whenever you create procedures named sp_% - even when Microsoft recommends it - you could find yourself tripping over these quasi-system objects.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp; &lt;br&gt;&lt;/p&gt;</description></item></channel></rss>