can not create IDENTITY property on DECIMAL datatype with scale >0

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 709
CREATE TABLE Employee
(
ID DECIMAL(20,2) not null IDENTITY(1,5),
Name INT
)


If you try to add IDENTITY property on the column with data type DECIMAL/NUMBERIC with scale > 0, then the below error occurs...

Msg 2749, Level 16, State 2, Line 1
Identity column 'ID' must be of data type int, bigint, smallint, tinyint, or decimal or numeric with a scale of 0, and constrained to be nonnullable.


To resolve the above error,

CREATE TABLE Employee
(
ID DECIMAL(20,0) not null IDENTITY(1,5),
Name INT
)

Comments or Responses

Login to post response