The invariant culture identifier is rejected by the FORMAT() function in SQL Server 2012 - by slepmog

Status : 

  Duplicate<br /><br />
		This item appears to be a duplicate of another existing Connect or internal item.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


10
0
Sign in
to vote
ID 800817 Comments
Status Closed Workarounds
Type Bug Repros 5
Opened 9/15/2013 8:12:18 AM
Access Restriction Public

Description

The built-in FORMAT() function rejects the invariant culture identifier as if it was invalid.

The identifier for the invariant culture in .NET is documented to be an empty string, '', and FORMAT() is documented to accept any such culture identifier, but the '' identifier is rejected by the function in the same way as any string containing random garbage:

select format(getdate(), 'Y', '');  -- Results in an error.


Note that providing a string contaning a single zero terminator character makes FORMAT() to use the invariant culture, which apparently happens because internal string comparison finds such string to be equal to the empty string:

select format(getdate(), 'Y', nchar(0));    -- Works, but looks like a hack
Sign in to post a comment.
Posted by Microsoft on 1/23/2014 at 3:41 PM
Thanks for submitting this feedback. This issue has been resolved, and the fix will be available in a future servicing release for SQL Server 2012.
Posted by Fabrice Michellonet on 11/29/2013 at 2:57 AM
Using nchar(0) may have dramatical results like stopping your SQL Server instance.
Here is an example of such a behavior :
DECLARE @val float
SET @val = 0.25
SELECT FORMAT(@val, 'F2', nchar(0))
Posted by Microsoft on 9/19/2013 at 5:28 PM
Thank you for submitting this feedback. We are investigating the issue and will update you when we have more information.
Posted by Microsoft on 9/19/2013 at 5:28 PM
Thank you for submitting this feedback. We are investigating the issue and will update you when we have more information.