SQL Server Decimals have changed - sql

I have jusrt uploaded an Access Database to SQL Server 2008 and the numeric fields have been changed to things like:
2.5364E-05,
2.5364E-05,
2.7598E-05,
2.8425E-05,
2.7598E-05,
2.5364E-05,
2.5364E-05,
I have seen this happen before, but now i need to know how to resolve it.
Is there any way to convert the numbers back, or avoid the problem in the first place?
Thanks all!
C

It's very unlikely that your data has actually been changed. This is a presentational effect that happens with the decimal data type.
Have you tried formatting the data using CONVERT(VarChar, ...)? What is the format you're expecting?

Related

Excel data type issues

I am using MS query to pull data from sql server and all is good.
Problem starts when data comes from the server I am stuck with data type general for everything, and no way to change the data type in excel.
Main issue is numbers, where in database datatype is decimal yet i can do no calculations on it in excel. Any help would be appreciated.
I am using excel to execute a stored procedure on server
This pulls the data into the following table
Even though the data in the sql server for column price is formatted as decimal it becomes a general data type after getting to excel.
Changing it to number/currency etc. does not change anything.
Also no errors appear. Simply data comes down and no matter what changes in excel I apply nothing changes it all is treated as text.
You can do these things.
Select Column
Click Data-> Text to Columns
Follow the wizard
Set the format
Use this official support ticket from Microsoft
Problem in this case was created by myself.
But I suppose it could easily happen to others who are just starting on their path with sql and excel.
Here is what happened as I established after few days of going in circles.
as there was load of trailing spaces in the data coming down from the server I have decided to tidy things up.
Without considerring implications I have stuck an RTRIM() on everything.
This caused excel to treat everything as strings as string RTRIM is a built in string function.
What made things worse is the fact that when using power query I was able to transform the data to the desired, formats.
Unfortunately MS query does not seem to be quite as clever as power query hence the issues.

Storing and returning emojis

What's the simplest way to write and, then, read Emoji symbols in Oracle table?
Currently I have this situation:
iOS client pass encoded Emojis: One%20more%20time%20%F0%9F%98%81%F0%9F%98%94%F0%9F%98%8C%F0%9F%98%92. For example, %F0%9F%98%81 means 😁;
Column type is nvarchar2(2000), so when view saved text via Oracle SQL Developer it looks like: One more time ????????.
This seems more a client problem than a database problem. Certain iOs programs are capable of interpreting that string and show an image instead of that string.
SQL Developer does not do that.
As long as the data stored in the database is the same as the data retrieved from the database, you have no problem.
After all, we do BASE64 encoding/decoding of the text. It’s suitable for small texts.
In MySQL the character set needs to be set to UTF-16 to be able to save emojis, I assume Oracle would need the same ch

how to convert image type to varchar sybase

after some time i landed in sybase (ASE 15.. to be specific) world and i am bit terrified over time
missing functions and functionality i know from sql server makes me feel like i am in early 90'
to the point
i have to prepare single shot report
an have some text stored as image column (dont know why someone did that)
so what i did was
select CAST(CAST(REQUEST AS VARBINARY(16384)) AS VARCHAR(16384)) as RequestBody
from table
the problem emarges becouse some requests are longer than 16384
and have no idea how to get the data
and what is even worse i dont know where to look for information as sybase documentation is in best case scarse, and in comparison with MS world its non existant
According to the docs you need to use CONVERT function like this:
SELECT CONVERT(VARBINARY(2048), raw_data) as raw_data_str FROM table;
Instead of using varbinary(16384) and varchar(16384), try using varbinary(max) and varchar(max). In that case, the maximum datalength will be 2 GB.
See:
http://msdn.microsoft.com/en-us/library/ms176089.aspx and http://msdn.microsoft.com/en-us/library/ms188362.aspx
What is the length of the REQUEST column in the table?

SQL SSIS Convert question

I have an excel file I'm converting to a prn in an SSIS package. My issue. One of my columns has currency, everything should have a decimal point but not all the numbers do. For example if there are no cents it simply reads 10425. What I need to happen in SSIS is to make is read 10425.00 just as the other numbers in the file already do.
Please help.
You can use the Derived Column transformation to convert the data type. I don't think think the Currency (DT_CY) data type will force the decimal places for you, but you can use the Decimal (DT_DECIMAL) data type.
(DT_DECIMAL,2)MyMoneyColumn
SSIS is relying on a registry key to determine how many rows to sample. If you are using default settings, then it may only be checking the first 8 rows. You can increase the number of rows it uses by modifying the TypeGuessRows key in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel. You can read about this here, here, here, and here.

Working around globalization issues when executing T-SQL

In an app, where SQL server databases with schemas and locale unknown at compile-time (determined at runtime) can be plugged in, I need to figure out how to update a decimal field - ie. what decimal separator to use.
So against one server, if I need to update a decimal field, I would send 100.125. On another server that would be interpreted as 100,125.
I use oldschool SqlCommand-class to do so, since I do not know the schema at compile-time.
At runtime, can I determine which separator I should use? Or is there another way of handling this, that I am overlooking?
There is some discussion on that issue here.
Can you supply some context to your query why just using a dot wouldn't work?
As far as I understand it
UPDATE tbl SET Col = 1.23
would work anywhere and you would only get problems if you did
UPDATE tbl SET Col = '1.23'