Decimal separator in Sql Server 2008 - sql-server

What do I need to change in Sql Server to be able to store values like "2,1" in a decimal field? Right now I have to have dots like "2.1".
I have Finnish_Swedish_CI_AS collation on the database but that doesn't seem to be it ... I also fiddled around with the regions settings on the server but with no success. I know I've managed to change this before.

In security, your login properties, set default language to Finnish or Swedish.
Although I'd prefer to format values into english standard and have default language set to english - this way storing data is independent of client regional settings.

Store the data as a regular number - change it only when you display it.

Related

Fun with US and UK dates on a new server

I have just had the task of moving an old ASP website / SQL DB to a new dedicated OVH server (French - all defaults set to US-Eng).
The DB has moved from SQL 2005 to SQL 2012 (web edition 64 bit).
I am having the old issue of date formats showing up as US format on the website e.g 8/3/2016 instead of 03/08/2016. This is even though in the database they are stored as ISO Date 2016-08-03 etc.
I enter the dates on the ASP Classic, website as UK format
e.g. 03/08/2016 and convert them to ISO format 2016-08-03 in the SQL that is passed to the Stored Procedure that has SET DATEFORMAT YMD at the top of it.
If I check the tables in the DB they are all stored correctly as ISO dates.
I have made sure all the SQL Logins to the DB have "British English" selected as their "Default Language".
If I view the database properties under options the Default Language is British English.
If I view the server properties under General->Language it's English (United States) but under Advanced->Default Language it's British English.
The dates are getting stored as ISO correctly as if I do a DATEDIFF(DAY,Stamp,GETDATE())=0 I can see all the records even though they are showing up on the website as US format 8/3/2016 (Why there are no zeros in front of US dates I don't know).
The ASP code hasn't changed or the DB code it was just ported into this new dedicated server and now I am getting these issues. I am sure I solved something like this ages ago just by changing the default login language but that doesn't seem to work on this box.
I am getting lots of Primary Key/Index errors due to duplicate insertions due to the dates (mixing up US/UK) from a .NET app I have that uses the Betfair API to get racing data e.g
EXEC dbo.usp_net_insert_betfair_market_selection #MarketID = 125932808, #SelectionID = 10593225, #Racedatetime = '2016-08-03 15:10:00', #MarketType = 'WIN', #HorseName = 'She Done Good';
Violation of PRIMARY KEY constraint 'PK_BETFAIR_MARKET_SELECTIONS'. Cannot insert duplicate key in object 'dbo.BETFAIR_MARKET_SELECTIONS'. The duplicate key value is (719859, WIN, Mar 8 2016 3:10PM).
However if I copy that EXEC statement and run it direct in a query analyser window it runs WITHOUT ANY ERROR.
I have been searching the web and I have seen someone suggest putting this code at the top of all ASP pages that show dates to force it show in UK format > https://www.webwiz.co.uk/kb/asp-tutorials/date-time-settings.htm
'* Set the server locale to UK
Session.LCID = 2057
This has worked on SOME pages but I have never had to do this before.
On pages with long lists of records and dates in one column I have wrapped the date in CONVERT(varchar, GETDATE(),103) in the SQL and it returns correctly on the page.
I am confused though as I have never had to do this on the old set up and it seems like there must be some setting that needs to change to fix all this on the new server (SQL and Web IIS 8) on same box.
I have tried going into the .NET Globalization for the site and changing Culture and UI Culture to English (en). However that didn't fix everything.
The "Language" preferences on the machine are set to English (UK) although I wouldn't have though that would have made a difference.
If I run this code in a query analyser either RD into the box, or through my local SQL console connected to the machine over the network
select name ,alias, dateformat
from syslanguages
where langid =
(select value from master..sysconfigures
where comment = 'default language')
In a query window (Remote Desktop into server) I get back
Name Alias dateformat
British British English dmy
Question
So it seems like something to do with the connection between the ASP website or .NET app and the server/database. Something I have missed or need to change as this all worked fine on the old WebServer -> Database Server setup we had.
Is there something I have overlooked to ensure dates are shown as UK on the website without editing every ASP page and SQL that contains dates as I never had to do that for the old setup.

In SSRS, how do I force the reporting server locale from English-US to English-GB?

I have an issue where all dates in parameters are displayed as mm/dd/yyyy:
My goal is to change the date format to dd/mm/yyyy, which would require changing the locale to English-GB. Things which I've currently tried (and didn't work):
Changing the Language within the individual report settings to English-GB
Checking the Windows locale setting on the SQL Server instance (it was already set to English-GB and dd/mm/yyyy)
Changing the default SQL Server language using EXEC sp_configure 'default language', 23 ;
Changing the Reporting Server's service account language using ALTER LOGIN [XXXXX] WITH DEFAULT_LANGUAGE = British
Restarting the Reporting Service
Killing all connections to the SQL Server instance to force a reconnect
Non of the above worked and I'm still seeing the dates in the wrong format. Is there anything else I can do?
I think actually this comes from the Language of the browser rather than Report Server - I could be wrong. Try changing from US English to GB English in IE or whatever you're using.

Sybase ASE 12.5 database : arabic data shown in latin letters

Good day,
i have a Sybase ASE 12.5 database on windows NT server
the database default charachterset is CP850
i'm trying to connect to it using "TOAD for sybase" ,which is on my windows 7 machine
whatever character set i choose for TOAD (utf8,cp1256..), the data are shown in latin letters instead of arabic
i tried disabling the "server character set conversion" ,and disabling the client side conversion,but still no hope
any ideas how to solve this?
CP850 is the character set for Western Europe, so that would explain the latin. If the character set used by the client does not match what is used in the server, then it defaults to English.
You need to change the character set of the server to match what you wish to use for the client, or install the UTF character set in the Server to allow Unicode use.
The Sybase ASE documentation explains the details of charactersets.
the problem were in the server itself, it was corrupted during cloning.
thanks for all the answers

Date format on reporting services

I installed SQL server and reporting services with him, when my regional settings is set to US, date format is been mm/dd/yyyy. Now, I changed region settings to German in tab Formats, Location and also System locale for non unicode programs.
My problem is that when I try to enter parameter for report, datetime format in report manager has same format like before mm/dd/yyyy. I try to re-create database for reporting services but with no luck.
I can not change application to send this us format to reporting services.
Windows server 2012 is OS.
Tnx...
There are a few things you can do:
You can try changing the Language on your report files (Properties - Location - Language) to match the same language on the database.
When you pass a parameter to a query, instead of using the parameter value, pass it as an expression like this: =Format(Parameters!Date.Value,"yyyyMMdd") which will convert it to a date format which will be accepted by any language setting on the database.
This got me for a while - finally found that you have to make sure the data type for the parameter (in the parameter properties) is set to datetime not text.

SQL Server 2000 charset issues

Once again with the charset issues when talking to DB's :)
I have two enviroments running Zend Server. Bot of these communicate to a SQL Server 2000 using the mssql extension. None of them has any value given for the charset in the settings of the extension. For one it works and for the other one it returns data in the wrong encoding.
The problem became noticed when this data was beeing inserted into a MySQL database and it screamed with SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF6m' for column 'cust_lastname' at row 1.
I tried using SET NAMES utf8 to get the SQL Server connection to return the correct data, but it complains and says that NAMES is not a recognized SET statement. Looking around most people even recommend using this but it doesn't seem to be part of SQL Server 2000 :)
So, what should I do? How do I, WITHOUT fiddling with the SQL Server database/tables, tell it to send me the data in UTF-8 encoded format?
EDIT:
Some more info...
SQL Server uses the Finnish_Swedish_CI_AS collation
MySQL has every table in UTF-8 format and uses utf8_unicode_ci
I didn't find a good solution and ended up converting to and from utf8 in my application. If this is encapsulated within a class it doesn't riddle the code. But a way to actually tell the SQL server which encoding to use during communication would be better.

Resources