I want some Moore

Blog about stuff and things and stuff...
mostly about SQL server and .Net
posts - 158, comments - 1438, trackbacks - 33

My Links

SQLTeam.com Links

News

Hi! My name is 
Mladen Prajdić  I'm from Slovenia and I'm currently working as a .Net (C#) and SQL Server developer. I'm also a MCP and MCTS for SQL Server. 
Welcome to my blog.

Search this Blog
 

My Blog Feed via Email


Get your Google PageRank
Users Online: who's online

Article Categories

Archives

Post Categories

Cool software

Other Blogs

Other stuff

SQL stuff

I want a culture insensitive decimal separator for Sql server

If there can be a culture insensitive format for dates (yyyymmdd) then why is there no such thing as a culture insensitive format for decimals?

I suggest a use of # or ~ instead of the decimal separator in update and insert scripts only.
And it would be allowed only in numeric/decimal/float datatypes.

so you could do:

create table t1 (MyDecimalCol decimal (16,3))
insert into t1 (MyDecimalCol)
select 123#456 union all
select 789#123

select MyDecimalCol 
from   t1
-- would give:
123.456 
789.123 -- or 123,456
789,123 -- depending on your locale

Wouldn't that be great?

I already suggested to Microsoft a culture neutral decimal separator a while back.

(Does anyone know the URL of the bug/feature request page on MS page? It's impossible to find it...)

Their answer was something like:
"Thanx for the suggestion. we'll look into it for the next verion of sql server."

So Katmai (SS2k7or8) better have this :)

 

UPDATE:

Thanx to Branko who pointed me to the MS feedback page in comments I found my submission of the problem.

You can look and vote for it here.

Print | posted on Tuesday, October 24, 2006 11:20 AM

Feedback

# re: I want a culture insensitive decimal separator for Sql server

SS2k7or8 !?
More like SP3 ;)

But it still won't help the front-end users.
You have to teach them the search&replace trick in Excel anyhow!

PS.
You have my support!
10/24/2006 9:20 PM | rockmoose

# re: I want a culture insensitive decimal separator for Sql server

SP3 of SS2k5 or Katmai? :)

who cares about front end users :)))
10/25/2006 10:20 AM | Mladen

# Re: I want a culture insensitive decimal separator for Sql server


MSDN Product Feedback Center Migration Information Page

http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220
10/25/2006 3:11 PM | Branko Hajdenkumer

# re: I want a culture insensitive decimal separator for Sql server

Thanx a lot Branko.
10/25/2006 3:15 PM | Mladen

# re: I want a culture insensitive decimal separator for Sql server

So the period isn't what some cultures use? Sorry for being ignorant. ;)
10/28/2006 2:02 AM | Tara

# re: I want a culture insensitive decimal separator for Sql server

I'll excuse you your ignorance. but just because it's you :)
10/28/2006 10:24 AM | Mladen

# re: I want a culture insensitive decimal separator for Sql server

Actually there IS a culture insensitive decimal separator in SQL. It's a dot. Whatever your culture settings are, this statement should produce what you want (regarding decimal digits, not the entire syntax):
create table t1 (MyDecimalCol decimal (16,3))
insert into t1 (MyDecimalCol)
select 123.456 union all
select 789.123

What IS culture sensitive is default conversion from string typed values to decimal typed values. For example this:
create table t1 (MyDecimalCol decimal (16,3))
insert into t1 (MyDecimalCol)
select '123.456' union all
select '789.123'
would work OK only if the dot is set as your decimal separator (in the SQL client application or other place valid and used by the application/protocol/database).

I'm not sure if all SQL dialects and/or engines really follow that rule. I'm sure, that most SQL enabled engines do accept decimal literals with dot (works in SQL Server 2000 and Oracle 8i / 9iR2 regardless of regional settings and client application settings) and dot only (using comma regardless of settings is a syntax error; checked as before), but the way they accept decimal separator in string-to-decimal conversions differs (eg. Enterprise Manager and Query Analyzer for SQL Server 2000 seem to ignore regional settings and allow only dot in string to decimal conversion or I have failed to find the settings that do affect this, but using TOAD against Oracle produces clear result - allows decimal separator set in NLS_NUMERIC_CHARACTERS for current session).

So if you are after universal decimal separator in decimal number literals, then there's a dot (just as in most other, also programming langages like C/C++/Pascal), but if it's about string to decimal number conversion, then (just as in C/C++/Pascal) it's up to the engine (and usualy you have a way to show the engine what decimal separator you'll be using).
5/18/2007 10:07 PM | Hilarion

# re: I want a culture insensitive decimal separator for Sql server

yes you're exactly right.
i was talking about string to decimal conversion.

if not you can just use parameters like it's supposed to be and not worry about dots and/or decimals. :)
5/18/2007 10:12 PM | Mladen

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 3 and 5 and type the answer here:

Powered by: