Link to home
Start Free TrialLog in
Avatar of maqskywalker
maqskywalker

asked on

displaying only 2 decimal places in a string field t-sql

i'm using sql server 2016.

I have a table that looks like this:

User generated image
The data looks like this:

User generated image

Here is script to create table:

USE [TestDatabase]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TestScores1](
	[RecordID] [int] NULL,
	[Score] [varchar](50) NULL
) ON [PRIMARY]
GO
INSERT [dbo].[TestScores1] ([RecordID], [Score]) VALUES (1, N'100.00000')
GO
INSERT [dbo].[TestScores1] ([RecordID], [Score]) VALUES (2, N'94.00001')
GO
INSERT [dbo].[TestScores1] ([RecordID], [Score]) VALUES (3, N'86.12345')
GO
INSERT [dbo].[TestScores1] ([RecordID], [Score]) VALUES (4, N'76.05365')
GO
INSERT [dbo].[TestScores1] ([RecordID], [Score]) VALUES (5, N'88.04563')
GO

Open in new window


How do i only display 2 decimal places in the [Score] column ?

I know that column should be decimal datatype.
But the existing table is varchar. I'm just querying an old table that was created like that.
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of maqskywalker
maqskywalker

ASKER

thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial