How to insert Price in SQLServer usimg decimal datatype

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sonia.sardana
    New Member
    • Jul 2006
    • 95

    How to insert Price in SQLServer usimg decimal datatype

    Can somebody tell me how to insert price using decimal datatype. I do it in the following way but error comes...ERROR--Table Created Successfully but records are not inserted.....

    create table products(vend_i d int,prod_id varchar(7),prod _price numeric(2,2))
    insert into products values(1001,'TN T1',04.78)
    insert into products values(1001,'TN T1',14.78)
    insert into products values(1002,'TN T2',15)
    insert into products values(1002,'TN T2',5)

    select * from products

    select vend_id from products where prod_price <= 5

    I want to select those vend_id where prod_price <=5
  • scripto
    New Member
    • Oct 2006
    • 143

    #2
    prod_price should be AT LEAST decimal(4,2)

    Comment

    • sonia.sardana
      New Member
      • Jul 2006
      • 95

      #3
      Thx Its working.
      Why so decimal is atleast (4,2)? Any reason.

      Comment

      • BobbyTables
        New Member
        • Feb 2014
        • 1

        #4
        Originally posted by sonia.sardana
        Thx Its working.
        Why so decimal is atleast (4,2)? Any reason.
        Because 4 is the max total amount of numbers. And 2 are the amount of decimal numbers.

        12.34 has 4 numbers and two decimal places.

        Comment

        Working...