1
votes

I want to create a SQL table with the following column datatypes.

  1. Name : Varchar
  2. Grade : Data will have “#” followed by numbers and also can be varchar. Eg : #1, #2, TML
  3. Sizes : Can be whole numbers and fractions. Eg: 26/30, 80, 85/69
  4. Average : Will be decimal numbers.

I have created table based on the above requirements:

CREATE TABLE [dbo].[Report_Proj](
[Name] [nvarchar](255) NOT NULL,
[Grade] [nvarchar](50) NOT NULL,
[Sizes] [float](10) NOT NULL,   
[Average][decimal](10, 10) NOT NULL

But when I insert data into this table I’m getting the error “Msg 8115, Level 16, State 8, Line 1 Arithmetic overflow error converting varchar to data type numeric. The statement has been terminated.”

Where could I possibly be going wrong. Need the above data for reporting purposes and will not have any arithematic calculations in future.

1

1 Answers

2
votes

just change the decimal value data type to (10,2)

declare  @Report_Proj TABLE (
    [Name] [nvarchar](255) NOT NULL,
    [Grade] [nvarchar](50) NOT NULL,
    [Sizes] [float](10) NOT NULL,   
    [Average][decimal](18, 2) NOT NULL)

    insert into @Report_Proj ([Name],[Grade],[Sizes],[Average])values ('ram','#1',26/30,10.2)

    select * from @Report_Proj