troubleshooting Question

including decimal point value

Avatar of -Dman100-
-Dman100-Flag for United States of America asked on
Microsoft SQL Server 2005
13 Comments1 Solution368 ViewsLast Modified:
I have the following database table and stored procedure that reads the data from the table (see code below).  The real datatype does not allow the value of 8.0.  It will always revert to just 8.  I can use 8.1, 8.2, 8.3, etc. but, whenever I try to enter just 8.0, the .0 decimal will not be accepted.  What is the easiest way to get the .0 decimal point to be accepted.  I have other values that do not need to show a decimal point, so I only need to show the .0 decimal point for this one record.  There are other records that have 4.7, etc.  Then other records with just a whole number value such as 25 without a decimal point.

Thanks for any help.
CREATE TABLE [dbo].[customer_service_metric](
	[metric_id] [int] IDENTITY(1,1) NOT NULL,
	[description] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[metric] [real] NULL,
 CONSTRAINT [PK_service_report_card] PRIMARY KEY CLUSTERED 
(
	[metric_id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
 
 
CREATE PROCEDURE [dbo].[spGetCustomerServiceMetrics]
 
AS
   SELECT metric_id,  description, metric =
	CASE metric_id
	WHEN 1 THEN CAST(metric AS VARCHAR(2)) + '%'
	WHEN 2 THEN CAST(metric AS VARCHAR(10)) + ' seconds'
	ELSE CAST(metric AS VARCHAR(10))
	END
FROM dbo.customer_service_metric
ASKER CERTIFIED SOLUTION
federicomarinucci

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros