How to insert into a table with just one IDENTITY column?

后端 未结 4 895
夕颜
夕颜 2020-12-08 06:22

(Came up with this question in the course of trying to answer this other one)

Consider the following MS-SQL table, called GroupTable:

GroupID
-------
1          


        
相关标签:
4条回答
  • 2020-12-08 06:28

    Here you go:

    INSERT INTO GroupTable DEFAULT VALUES
    
    0 讨论(0)
  • 2020-12-08 06:30

    Can you try using a Sequence or something similar? Where you select from a Sequence and it will give you the next value in the sequence.

    0 讨论(0)
  • 2020-12-08 06:42

    This should work:

    INSERT INTO GroupTable DEFAULT VALUES 
    
    0 讨论(0)
  • 2020-12-08 06:49

    It is possible to insert more than one row at a time.

    For e.g., to insert 30 rows. INSERT INTO GroupTable DEFAULT VALUES GO 30

    This will insert 30 rows by incrementing the identity column each time.

    0 讨论(0)
提交回复
热议问题