<?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 'SSMS', 'deferred name resolution', 'documentation', and 'SQL Server 2008'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=SSMS,deferred+name+resolution,documentation,SQL+Server+2008&amp;orTags=0</link><description>Search results matching tags 'SSMS', 'deferred name resolution', 'documentation', and 'SQL Server 2008'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Connect Digest : 2009-08-22</title><link>http://sqlblog.com/blogs/aaron_bertrand/archive/2009/08/21/connect-digest-2009-08-22.aspx</link><pubDate>Sat, 22 Aug 2009 03:18:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:16113</guid><dc:creator>AaronBertrand</dc:creator><description>&lt;p&gt;I rounded up a few interesting items this week.
&lt;/p&gt;
&lt;hr style="height:1px;"&gt;
&lt;p&gt;&lt;b&gt;Does "1/10/1900" mean January 10th, or October 1st?&lt;/b&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;This item demonstrates that Microsoft isn't all that concerned about publishing sample code that uses ambiguous or troublesome formats for date literals.&amp;nbsp; Initially the Books Online topics mentioned in the item used "1/10/1900" as a date literal, and of course that would have a different meaning in a default US English locale compared with a British locale.&amp;nbsp; The alleged 'fix' was to change the string to "January 1, 1900."&amp;nbsp; Which will simply fail if the user has, for example, SET LANGUAGE FRENCH.&amp;nbsp; It seems funny that they could make a change for the better within a few days, but then making another change (also for the better) cannot be done due to costs.&amp;nbsp; Whereas if they had just changed "1/10/1900" to "19000101" in the first place, the problem would have been solved in one step.&amp;nbsp; What a weird organization they have over there; I personally think that the people writing their documentation samples should be assigned random locales and SET LANGUAGE settings so that they aren't writing code in a nice little US English vacuum.&amp;nbsp; I can imagine a scenario where you have a bank of servers to deploy to, and you have to test on one of them, but you never know which one you're going to get... when your code blows up because the German server with SET LANGUAGE DUTCH doesn't know what "February" means, you have to go back to the drawing board.&amp;nbsp; And I think this would be beneficial for everyone.&lt;br&gt;&lt;/p&gt;
&lt;div style="margin-left:40px;" class="SubTitle"&gt;&lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=482186" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=482186" target="_blank"&gt;#482186 : DOC : Add/Subtract topics should warn about DATE / TIME types&lt;/a&gt;&lt;br&gt;&amp;nbsp;&lt;/div&gt;

&lt;hr style="height:1px;"&gt;
&lt;p&gt;&lt;b&gt;Why can't we have an easier way to get first day of month, of year, etc.?&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;We currently use clumsy methods to get the first day of the week, month or year (given a DATETIME/SMALLDATETIME value), or to strip the time.&amp;nbsp; While the DATE data type in SQL Server 2008 will relieve some of this pain, it won't help in all cases.&amp;nbsp; Meanwhile, other RDBMS have much more convenient ways to do this (e.g. Oracle's TRUNC()).&amp;nbsp; I am hopeful that someday they will add a function like this to SQL Server; I call it "DATEROUND."&lt;/p&gt;

&lt;blockquote&gt;&lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=483913" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=483913" target="_blank" id="ctl00_MasterBody_PostedByUserView_ctl01_FeedbackSummaryDisplay_FeedbackLink"&gt;#483913 : Add a DATEROUND 
function similar to Oracle's TRUNC() for date handling&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=482186" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=482186" target="_blank"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;hr style="height:1px;"&gt;
&lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=482186" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=482186" target="_blank"&gt;&lt;/a&gt;
&lt;p&gt;&lt;b&gt;Why do we allow identifiers with trailing spaces?&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;While this may not be common practice (notice the trailing spaces in the table and column names)...&lt;/p&gt;

&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;CREATE&amp;nbsp;TABLE&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;dbo.[foo&amp;nbsp;]&lt;br&gt;&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;[bar&amp;nbsp;]&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;INT&lt;br&gt;&lt;/font&gt;&lt;font color="gray"&gt;);&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;/table&gt;

&lt;p&gt;...there are end users complaining about the fact that this works (see &lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=483389" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=483389" target="_blank"&gt;Connect #483389&lt;/a&gt;).&amp;nbsp; I had a slightly different take than user "aitcha1" in that I don't understand why SQL Server allows trailing spaces in identifier names in the first place.&amp;nbsp; It does ignore trailing spaces when preventing duplicates (for example, you can't have a column named [bar] and a column named [bar ]), but in spite of what the documentation says, it certainly keeps the space intact when storing the metadata in the catalog views.&amp;nbsp; So I filed two suggestions: one to fix the documentation to be more explicit about how "SQL Server stores the name without the trailing spaces," and one to actually tighten up identifier rules.&lt;/p&gt;

&lt;div style="margin-left:40px;" class="SubTitle"&gt;&lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=483553" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=483553" target="_blank"&gt;#483553 : DOC : Delimited Identifiers topic lies about trailing spaces&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-left:40px;" class="SubTitle"&gt;&amp;nbsp;&lt;/div&gt;&lt;div style="margin-left:40px;" class="SubTitle"&gt;&lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=483527" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=483527" target="_blank"&gt;#483527 : Tighten up identifier rules&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/div&gt;

&lt;hr style="height:1px;"&gt;
&lt;p&gt;&lt;b&gt;Why does SSMS not like VARCHAR(MAX) parameters?&lt;/b&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;There was an avid discussion on the newsgroups this week about a long-acknowledged bug in SSMS.  If you have a stored procedure that has a VARCHAR(MAX) parameter, and you open Object Explorer, right-click the procedure and choose Script As &amp;gt; Execute &amp;gt; New Query Window, the variable declaration for that parameter is simply VARCHAR, not VARCHAR(MAX).  Obviously this isn't a huge show-stopper, and an easy workaround is to use NVARCHAR(MAX) parameters (if this is acceptable), but I also believe that this can't be a very difficult bug to fix.&amp;nbsp; I tried to use Profiler to peek at what SSMS calls when you run this script, but they are only retrieving metadata and not revealing how they are actually building the output that you ultimately execute.&amp;nbsp; My guess is that there is just a bug when handling VARCHAR() types where max_length = -1.&amp;nbsp; Anyway the bug has been sitting around for almost three years and could possibly use a little traffic.&lt;br&gt;&lt;/p&gt;
&lt;div style="margin-left:40px;" class="SubTitle"&gt;&lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=241782" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=241782" target="_blank"&gt;#241782 : create script for sp execute in parameter varchar(max) wrong&lt;/a&gt;&lt;br&gt;&amp;nbsp;&lt;/div&gt;

&lt;hr style="height:1px;"&gt;
&lt;p&gt;&lt;b&gt;Who coded that infinite loop?&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;In several Windows collations (e.g. Latin1_General_CI_AS), when performing a REPLACE() of CHAR(0), the SQL engine can enter an infinite loop and consume multiple CPUs.&amp;nbsp; A problem with CHAR(0) was first reported by Erland back in 2006, but the infinite loop was a much more recent revelation (it was added in a comment this week, and may appear in an independent Connect item in the future).&lt;br&gt;&lt;/p&gt;

&lt;p style="margin-left:40px;"&gt;&lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=125502" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=125502" target="_blank"&gt;#125502 : Replace of char(0) does not work in DB with Windows collation&lt;br&gt;&lt;br&gt;&lt;/a&gt;&lt;/p&gt;

&lt;hr style="height:1px;"&gt;&lt;br&gt;&lt;b&gt;Can we have an option to turn off deferred name resolution?
&lt;/b&gt;
&lt;p&gt;Deferred name resolution is confusing, and has even created a market for 3rd party products that track dependencies  better than SQL Server can do on its own (e.g. Red-Gate's &lt;a href="http://www.red-gate.com/products/SQL_Dependency_tracker/index.htm" title="http://www.red-gate.com/products/SQL_Dependency_tracker/index.htm" target="_blank"&gt;SQL Dependency Tracker&lt;/a&gt;).&amp;nbsp; We know that if we create a stored procedure that calls another stored procedure that doesn't yet exist, the parser still allows us to create the procedure, giving us the benefit of the doubt that we will create the other procedure later.&amp;nbsp; So in this case, we get a warning message:&lt;/p&gt;


&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;CREATE&amp;nbsp;PROCEDURE&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;dbo.test1&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;EXEC&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;dbo.proc_does_not_exist&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 color="blue"&gt;GO&lt;/font&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;br&gt;
&lt;table bgcolor="#efefef" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;Cannot add rows to sys.sql_dependencies for the stored procedure because it depends &lt;br&gt;on the missing table 'dbo.proc_does_not_exist'. The stored procedure will still be &lt;br&gt;created; however, it cannot be successfully executed until the table exists.&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;


&lt;p&gt;The warning message incorrectly says "table" when it should probably say "object."&amp;nbsp; In SQL Server 2008, the error message is actually: &lt;br&gt;&lt;/p&gt;

&lt;table bgcolor="#efefef" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;The module 'test1' depends on the missing object 'dbo.proc_does_not_exist'. The module &lt;br&gt;will still be created; however, it cannot run successfully until the object exists.&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;Sadly, we don't get a warning or an error if we reference a table that doesn't yet exist:&lt;/p&gt;


&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;CREATE&amp;nbsp;PROCEDURE&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;dbo.test2&lt;br&gt;&lt;/font&gt;&lt;font color="blue"&gt;AS&lt;br&gt;BEGIN&lt;br&gt;&amp;nbsp;&amp;nbsp; SELECT &lt;font color="gray"&gt;*&lt;/font&gt; FROM &lt;/font&gt;&lt;font color="black"&gt;dbo.table_does_not_exist&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 color="blue"&gt;GO&lt;/font&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;br&gt;
&lt;table bgcolor="#efefef" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;Command(s) completed successfully.&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;This was complained about in &lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=246014" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=246014" target="_blank"&gt;Connect #246014&lt;/a&gt;, which was closed as fixed, however the parser is still silent about the problem in SQL Server 2008 (where we are told it has been addressed).&amp;nbsp; I guess the "fixed" part is just that the error message when the referenced object is NOT a table no longer incorrectly says "table."&amp;nbsp; :-(&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Deferred name resolution falls completely on its face if we reference a column that DOES NOT (yet) exist, in a table that DOES exist.&amp;nbsp; Where is our benefit of the doubt now?&amp;nbsp; This stored procedure won't compile, even if we intend to go create the column immediately:&lt;/p&gt;


&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;CREATE&amp;nbsp;TABLE&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;dbo.foo&lt;br&gt;&lt;/font&gt;&lt;font color="gray"&gt;(&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="black"&gt;bar &lt;/font&gt;&lt;font color="blue"&gt;INT&lt;br&gt;&lt;/font&gt;&lt;font color="gray"&gt;);&lt;br&gt;&lt;/font&gt;&lt;font&gt;&lt;font color="blue"&gt;GO&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;br&gt;&lt;font color="blue"&gt;CREATE&amp;nbsp;PROCEDURE&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;dbo.test3&lt;br&gt;&lt;/font&gt;&lt;font color="blue"&gt;AS&lt;br&gt;BEGIN&lt;br&gt;&amp;nbsp;&amp;nbsp; SELECT &lt;/font&gt;&lt;font&gt;&lt;font color="black"&gt;column_does_not_exist&lt;/font&gt;&lt;/font&gt;&lt;font color="blue"&gt; FROM &lt;/font&gt;&lt;font color="black"&gt;dbo.foo&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 color="blue"&gt;GO&lt;/font&gt;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;/table&gt;

&lt;br&gt;
&lt;table bgcolor="#efefef" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="red"&gt;Msg 207, Level 16, State 1, Procedure test3, Line 3&lt;br&gt;Invalid column name 'column_does_not_exist'.&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;


&lt;p&gt;As alluded to, dependency tracking gets better in SQL Server 2008, as *some* unresolved dependencies are stored in sys.dm_sql_referenced_entities.&amp;nbsp; I wrote a lengthy blog post about this last year:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2008/09/09/keeping-sysdepends-up-to-date-in-sql-server-2008.aspx" title="http://sqlblog.com/blogs/aaron_bertrand/archive/2008/09/09/keeping-sysdepends-up-to-date-in-sql-server-2008.aspx" target="_blank"&gt;Keeping sysdepends up to date in SQL Server 2008&lt;/a&gt;&lt;br&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;p&gt;But I would still like to make it impossible to create anything (even a synonym) that references an object that doesn't yet exist.&amp;nbsp; Erland goes into much more detail about this in &lt;a href="http://www.sommarskog.se/strict_checks.html" title="http://www.sommarskog.se/strict_checks.html" target="_blank"&gt;his paper on SET STRICT_CHECKS ON&lt;/a&gt;.&amp;nbsp; You can't vote on that, but you could vote on these:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=127152" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=" target="_blank"&gt;#127152 : Ability to disable or workaround deferred name resolution&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=287100" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=287100" target="_blank"&gt;#287100 : Turn off deferred name resolution for CREATE SYNONYM&lt;/a&gt;&lt;/p&gt;
&lt;a href="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=260762" title="http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=260762" target="_blank"&gt;#260762 : Add optional checks for more robust development&lt;/a&gt;&lt;br&gt;&lt;/blockquote&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>