No Decimals In Query
Jun 24, 2008in quantity column - i have
100.00000
but i want only 100
no decimals..
how to get that?
thanks
in quantity column - i have
100.00000
but i want only 100
no decimals..
how to get that?
thanks
I have two fields whose format in the table is decimal (14,5).
I now have to divide one field by the other, and I want the result
to be in the format decimal (21,16).
Whatever I do I'm not able to get this result with sixteen decimals.
I tried with dec(Field1,21,16)/Field2 but it yields six decimals.
I tried with dec(Field1,21,16)/Field2 but it yields an integer.
I tried other ways but I always get a result which is made of maximum
six decimals.
What can I do?
Thank you.
Anna - Verona (Italy)
I am trying to use bcp to load a text file into SQL Server 7. The decimal numbers in the text file are formatted as 123455 and when I load the values to SQL I want the last two digits to be the decimal 1234.55. My current process is loading the value as 123455.00. What do I need to do in the format file to get this to work???
View 2 Replies View RelatedHi all,
This is what I have:
DECLARE @OnTime int
DECLARE @UnControlled int
DECLARE @Volume int
DECLARE @GrossEffect decimal(10,2)
DECLARE @NetEffect decimal(10,2)
DECLARE @WeekEndDate datetime
SET @OnTime = (SELECT COUNT(DataID) FROM tblEDITempARS WHERE OnTimeFlag = 1 AND ARSScanType = 'D' AND ARSType='AN')
SET @UnControlled = (SELECT COUNT(DataID) FROM tblEDITempARS WHERE ControlFlag = 'U' AND ARSScanType = 'D' AND ARSType='AN')
SET @Volume = (SELECT COUNT(DataID) FROM tblEDITempARS WHERE ARSScanType = 'D' AND ARSType='AN')
SET @GrossEffect = (@OnTime/@Volume * 100)
SET @NetEffect = ((@OnTime + @UnControlled)/@Volume * 100)
SET @WeekEndDate = (SELECT DISTINCT WeekEndDate FROM tblEDITempARS)
INSERT INTO tblSummaryData2(ReportType, Volume, NetEffect, GrossEffect, WeekEndDate)
VALUES ('AN',
@Volume,
@NetEffect,
@GrossEffect,
@WeekEndDate)
My numbers are:
OnTime=8089
Uncontrolled=6
Volume=8095
The GrossEffect comes as 0 and the NetEffect=100
AN809501002/21/2004
Why is my GrossEffect = 0??? it should be 99.9
Hello, I have a table with a field with the format of 8 decimals. When I make a select to that table instead is given me (for example) 25,00 it gaves me 25,00000000. How can I fix the with the correct format? Thanks in advance.
View 2 Replies View RelatedI need to display decimal results from SQL Server queries, but the decimals keep getting truncated. For example, 9 divided by 4, keeps getting truncated to 2. Does anyone know how to display the whole result, including the decimals?
View 2 Replies View RelatedI have a field in my SQL table that is defined Decimal(10,8), which
provides me with the ability to have up to 8 digits after the decimal
place, however, if I store a value such as 3.14, it is stored as
3.14000000. This is fine in the database, but it is the same when it's
returned. I have tried using Convert.ToDecimal on my returned row but
it doesn't work. The value at runtime appears as 3.14D in the locals
window but displays with all the insignifcant digits.
Any ideas what's happening or if there is an easy way to trim the trailing zeros?
Hello,
I want a view to always present my numeric fields with 2 decimals. In my table I have the following values in field "amount" (numeric(18,2))
181.25
176.5
170
I want the view to show
181.25
176.50
170.00
I have tried Cast but that doesn't seem to do the job.
Help!
Rolf
I am relatively new to SQL server. I am tring to send some decimalvalues to the database using a stored procedure with parameters of typeDECIMAL. Every time it inserts the values into the database thedecimals are truncated. I saw on the MSDN library that you have to setthe precision and scale values b/f you run the stored procedure. So Iset the precision to 8 and the scale to 4 and it still didn't help. Cananyone help me?
View 6 Replies View RelatedI'm using the sum() agregate function inside a select with a decimal field with an scale of 2.
I want to get the result always with 2 decimals, but if the result is 100.10 I get 100.1 . I've tried
to convert and cast the result but I can't find how to get 2 decimals. Please help. Thanks
Hello,
I have encountered a problem doing an update on a Field defined as DECIMAL with dbcursor().
I have opened a cursor with dbcursoropen() with option LOCK_CC set. Then I have bound some char variables to CHAR Fields with STRINGBIND and some double Variables to the DECIMAL fields with FLT8BIND.
When I read the cursor, the data is correct in the bound variables. But when I do an update, all data for the numeric fields are gone and the database contains only NULL Values. The Strings are updated correctly.
I have tried to set the length, I am using the poutlen-variables with a value other than 0, but nothing helps.
Does anyone have an idea about what can I do?
Thank You in advance.
Frank
In my select query for field ordernumber want to add two trailing zeros in the resultset, how can i add.
Thanks for the info.
How can i add two trailing decimals if there is no decimals:
for example if it is just 1, then make it 1.00
if it is 1.12 then leave it as it is.
can you please help.
select cast(ordernumber as varchar(10)) + '00' from ordertable
Thanks for the info.
Hello
I need a help ..
I need to convert 45.4593251 to 45.46
How to achieve it.
Can any one help me please..
Thanks
Ganesh
Solutions are easy. Understanding the problem, now, that's the hard part
I want to save a decimal in my sql table. It's an hourly rate. I have my field as smallmoney type. I am updating the table using a sp from my web page. It always rounds my entry up eg 3.75 becomes 4.00. Heres my sp and the line where I am passing the parameter to the sp.
CREATE PROCEDURE spRB_AmendRoomData
@strRoomId int,
@strRoomRef nvarchar (50),
@strFloor nvarchar (50),
@strZone nvarchar(10),
@strLocation nvarchar (100),
@strType nvarchar(50),
@strNo int,
@strDirections nvarchar(2000),
@strPhoneNo nvarchar (50),
@strMaxNo int,
@strEquipmentFac nvarchar(2000),
@strNotes nvarchar(2000),
@strCharge smallmoney,
@strNotInUse bit,
@strIntExt nvarchar(20)
AS
BEGIN
UPDATE tblRB_Rooms SET
RM_RoomRef=@strRoomRef,
RM_Floor=@strFloor,
RM_Zone=@strZone,
RM_Location=@strLocation,
RM_Type=@strType,
RM_No=@strNo,
RM_Directions=@strDirections,
RM_PhoneNo=@strPhoneNo,
RM_MaxNo=@strMaxNo,
RM_Equipment_Facilities=@strEquipmentFac,
RM_Notes=@strNotes,
RM_Charge=@strCharge,
RM_NotInUse=@strNotInUse,
RM_IntExt=@strIntExt
WHERE
RM_RoomId = @strRoomid
END
GO
Cmd.Parameters.Add(New SqlParameter("@strCharge", Me.txtCharge.Text))
Thanks for any help
Can someone suggest a FAST way to select Currency values where the number has more than X decimal places? There are zillions of rows so looping in code is not the preferred solution.
(a bug forgot to round)
Thanks for your help
I have the following field(Fields!SequenceNO.Value), coming form database.
i would like to have an expression IIF...
if the value coming from database is just 1, then make it 1.00 or
if the value coming from database has a period or point say 1.01 then show as it is.
thank you very much for the help / information....
Script as follows :
select cast( 0.0050000000 as decimal(38,23)) * cast(0.0000010000 as decimal(38,23))
select cast( 0.0050000000 as decimal(28,23)) * cast(0.0000010000 as decimal(28,23))
select cast( 0.01 as decimal(28,15)) * cast(0.0000000001 as decimal(28,15))
select cast( 0.01 as decimal(28,16)) * cast(0.0000000001 as decimal(28,16))
The result was following:
0.0000000--was zero
0.000000005000000000000000000
0.00000000000--was zero
0.0000000000010
Hi,
Im having a decimal value of 1.24
im rounding off the value to 1 precision
ex:- select round(1.24,1)
the output its returning is 1.20
i want to get only 1.2
can anyone suggest on this??
I am trying use the decimal data type for a field in SQL Server. When I input the values below, they round off.
73.827 Rounds to 74
1925.1 Rounds to 1925
119.79 Rounds to 120
What am I missing? Access never gave me this issue. Do you see any reason this would happen? I am entering the values into the table directly!
I have a table I am trying to create and one of the columns needs to have a decimal that appears as 00.00 and does not round because the data example is 87.09, 86.50, 98.55 etc. I have tried every type of decimal formatting when creating I can find and nothing has worked. When I create the table and upload the data it keeps rounding like this: 87.00, 87.00, 99.00
The only way it does not round is if I do it as a char but that does not seem right when dealing with numerics.
what re the sql functions to manipulate numbers, decimals, dates..
1/ like if I have 123443.78654 I want to display just 2 decimals : 123443.78 or 3 decimals ..
2/ also if I want to have bankers rounding
3/ how about dates conversion : from string to date type and vice versa and adding dates, substracting dates, getting the day, the month....
what re the SQL functions to do that pls
I have a table which I want to update by dividing one field intoanother. The update runs with no errors, but the results come out asonly a positive integer number.The datatype for the result field is float.The datatype for the other fields are int.I have tried testing by dividing 7 by 10000, which should give me0.0007. The result in the database is 0.How do I define a field to show the full value with decimal positions?If I enter .0007 into the field through the Enterprise Manager, it shows0007. When I update by dividing, it shows 0.Any help would be welcome.Joel*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
View 15 Replies View RelatedGoodday All
I wonder if anyone can help?
I want to set an integer (int) as a data type , but I want it also to accept decimals.
What must I set the data type as , when making my table?
Thanks
Rob
I'm new to SQL so please walk me through this step by step.
All the columns in my table have a data type of nvarchar, however, some of them need to be changed to decimals.
Here's an example of what my table (cicc.972file) looks like now
Account nvarchar(8) Balance nvarchar(8) Percent nvarchar(5)
45678935 459600 03500
78965215 005643 10000
and here's what I need it to look like
Account Number Balance Percent
45678935 4596.00 0.3500
78965215 56.43 1.0000
This seems like it should be ridiculously easy, but I keep running into road blocks. Like I said, this is just a sample from my table. My real table has 90 columns in it and about half of them need to be changed to either a dollar representation or a percent.
Thanks for you help!
I have a number 8.30 how can I break apart the 2 parts of this
for more simplicity I need to take out 8 and 30 in 2 different variables, how can I do it
Please advice
Hi, I was wondering how I can have the integer og a number that haves decimals.
I tried with FLOOR and ROUND function but it didn't work.
Does anyone knows how to do this?
Thanks
Beli
I am trying to get a decimal value from this simple user defined function, but it is not working. CREATE FUNCTION dbo.GETANSWERRETURNS decimal(6,2)ASBEGIN DECLARE @Result decimal(6,2)
SELECT @Result = 10 / 4
RETURN @Result
ENDThe real answer is 2.5, but I keep getting 2. Also, if I replace 10 / 4 with 3 / 4, I get the answer 0. I tried several things like changing decimal to numeric and still get the same results.
Hello,
I'm trying to import data from an Excel sheet into a table. Not all of them is imported.
Exl: 0,000801054857569349 becomes
Sql: 0,000801054857569350 when it is imported.
The column in SQL-Server is defined as DECIMAL 28.18, should take all 18 numbers i thought. Tried 28.19 also but it only added another zero at the end.
I've tried importing via DTS and manually import,same result both times.
Any suggestions?
Hi,
I want to display data that is 10 as $10.00 or 10.1 as $10.10..
and i tried giving this expression
=IIf(Fields!Nav.Value = "n/a","n/a",(cstr(Format(Fields!Nav.Value,"C2"))))
But when i run the report its giving it as C2 and not $10.00 or whatever it should be.
any help will be appreciated.
Regards
Karen
If I pull a value from a MSSQL field with is defined as money, how can I get it to display in a textbox with commas and NO decimals?
87000.0000 = 87,000
I can currently remove the decimals like below but is there a way to add the commas as well?
decRevenue = drMyData("Revenue")
txtRevenue.Text = decRevenue.ToString("f0")
It current shows "87000".
I'm running a query, actually its an insert that works when using the TSQL below.
However when I try to use the debugger to step through and using the exact same values as those below I get the following error:
[Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification
Its Killing me because everything else works, but this. Can somebody help.
DECLARE @NoteID INT,-- NULL OUTPUT,
@Note_Description NVARCHAR(3000),-- = NULL,
@Date DateTime,-- = NULL OUTPUT,
@ByWho NVARCHAR(30),-- = NULL,
@FK_Action_Performed NVARCHAR(40),-- = NULL,
@FK_UserID INT,-- = NULL,
@FK_JobID INT,-- = NULL,
@Job_Date DateTime,-- = NULL,
@Start DateTime,-- = NULL,
@Finish DateTime,-- = NULL,
@BeenRead NVARCHAR(10),-- = NULL
@FK_UserIDList NVARCHAR(4000)-- = NULL
--SET @NoteID = 409 --NULL OUTPUT,
SET @Note_Description = 'Tetsing'
--SET @Date DateTime = NULL OUTPUT,
SET @ByWho = 'GeorgeAgaian'
SET @FK_Action_Performed = 'Worked hard'
SET @FK_UserID = 5
SET @FK_JobID = 29
SET @Job_Date = 28/01/03
SET @Start = '1:00:20 PM'
SET @Finish = '1:00:20 PM'
SET @BeenRead = 'UnRead'
SET @FK_UserIDList = '1,2,3'
--AS
--SET NOCOUNT ON
SET NOCOUNT ON
SET XACT_ABORT ON
BEGIN TRANSACTION
SET @Date = GETDATE()
-- Insert Values into the customer table
INSERT Note (Note_Description,
Date,
ByWho,
FK_Action_Performed,
FK_UserID,
FK_JobID,
Job_Date,
Start,
Finish)
SELECT --@NoteID,
@Note_Description,
@Date,
@ByWho,
@FK_Action_Performed,
@FK_UserID,
@FK_JobID,
@Job_Date,
@Start,
@Finish
-- Get the new Customer Identifier, return as OUTPUT param
SELECT @NoteID = @@IDENTITY
-- Insert new notes for all the users that the note pertains to, in this case this will be by the assigned
-- users.
IF @FK_UserIDList IS NOT NULL
EXECUTE spInsertNotesByAssignedUsers @NoteID, @FK_UserIDList
-- Insert New Address record
-- Retrieve Address reference into @AddressId
-- EXEC spInsertForUserNote
-- @FK_UserID,
--@NoteID,
-- @BeenRead
-- @Fax,
-- @PKId,
-- @AddressId OUTPUT
COMMIT TRANSACTION
--------------------------------------------------
GO
ok can someone tell me why i get two different answers for the same query. (looking for last day of month for a given date)
SELECT DATEADD(ms, - 3, DATEADD(mm, DATEDIFF(m, 0, CAST('12/20/2006' AS datetime)) + 1, 0)) AS Expr1
FROM testsupplierSCNCR
I am getting the result of 01/01/2007
but in query analizer I get the result of
12/31/2006
Why the different dates