May 27, 2018 at 8:02 pm
I am importing data from excel and there is a column which contains % symbol for example 15%,I want to save 15% in a column,I tried using nvarchar but it converts 15% to 0.15, I dont want conversion ,I want to save valuea as 15% in that specific column,KIndly suggest which datatype should I use.
May 27, 2018 at 11:20 pm
A percentage is just a decimal type with X integers and Y decimals.
Most cases will store percentages as decimal (9, 4) but this is always going to depend on the business rules.
As for storing the symbol there is no data type for it other than char datatypes - but this should not be used on this case.
And the reason why you see .15 being stored is because Excel stores it as a decimal value internally. Displaying 15% is just a function of the interface, not of the database.
May 28, 2018 at 1:16 pm
tara.ajith1 - Sunday, May 27, 2018 8:02 PMI am importing data from excel and there is a column which contains % symbol for example 15%,I want to save 15% in a column,I tried using nvarchar but it converts 15% to 0.15, I dont want conversion ,I want to save valuea as 15% in that specific column,KIndly suggest which datatype should I use.
You've missed one of the basic principles of SQL and RDBMS and modern programming. There was a language called COBOL, which represented data as text strings, complete with punctuation, but we got over it. Modern languages divorce the physical storage from the display format. In fact, in RDBMS and other tiered architectures, they are totally separated. A program must pass data from one tier to the other. One such languages SQL and you're trying to write in it.
Punctuation marks like percentage or dollar signs are never, never, never part of the internal storage of the data. Again, that was COBOL 50+ years ago. You really need to update your programming skills by at least half a century 🙁
Please post DDL and follow ANSI/ISO standards when asking for help.
May 29, 2018 at 10:32 am
jcelko212 32090 - Monday, May 28, 2018 1:16 PMtara.ajith1 - Sunday, May 27, 2018 8:02 PMI am importing data from excel and there is a column which contains % symbol for example 15%,I want to save 15% in a column,I tried using nvarchar but it converts 15% to 0.15, I dont want conversion ,I want to save valuea as 15% in that specific column,KIndly suggest which datatype should I use.You've missed one of the basic principles of SQL and RDBMS and modern programming. There was a language called COBOL, which represented data as text strings, complete with punctuation, but we got over it. Modern languages divorce the physical storage from the display format. In fact, in RDBMS and other tiered architectures, they are totally separated. A program must pass data from one tier to the other. One such languages SQL and you're trying to write in it.
Punctuation marks like percentage or dollar signs are never, never, never part of the internal storage of the data. Again, that was COBOL 50+ years ago. You really need to update your programming skills by at least half a century 🙁
Once again with your condescending attitude. Don't you have anything better to do than just criticize? Being helpful isn't about criticism as much as it is about educating and informing without judging...
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply