SQL Server : row_number over primary key
问题 Is there any way to create column that will be increased and reset over primary key? Example: Table A ([Code], [Type], [Line No_]) Primary key is ([Code], [Type]) And when I add a new row, I want to auto generate [Line No_] like this: Code Type Line No_ ----------------------- 'U1' 0 1000 'U1' 0 2000 'U1' 1 1000 Something like ROW_NUMBER but auto generated on insert row 回答1: No, you can't use a window function in a computed column. Computed columns must be scalar values. However, this is a