I’m creating an ssrs report and creating a mockdata sql script.
In the script I want to insert a decimal value like so:
declare @tempTable table( aString varchar(50), aDecimal decimal(5,2) ) insert into @tempTable values ("somestring", 1,23)
The values after “someString” are actually one decimal value with a comma as decimal separator. SQL interprets this as separate values though and hence throws an error about too many values for the number of columns. How to go about this?
UPDATE
To clarify: I’m in a region where ‘.’ is a thousand separator and ‘,’ is a decimal separator.
Putting it in between quotes doesn’t work either. It gives me the Error converting data type varchar to numeric
message
Advertisement
Answer
To specify a number as a constant in a SQL script, you should follow SQL syntax rules, not locale settings. And the syntax dictates that you use a .
as a decimal separator. As for thousand separators, they are not used at all.
Note that this is strictly about coding your data in a script, not displaying them. Displaying is where your locale settings do matter, and if they are in order you should get your output formatted accordingly: decimal separators as commas, thousand separators as periods.