Inserting into table with only an identity column

  • I am replacing a VB.NET gui app with Java, against a database where the structure cannot be modified.

    I need to do an insert into a table which has a single column - and that column is an identity column. The table is used to as a reference list of "people" entities in the database - the table is called ACTOR.

    Problem is, the existing VB.NET code works by using an ADODBRecordset, calling AddNew() then Update() to add a new row. However, for the life of me I cannot find a way of replicating this using SQL.

    I have tried:

    insert into actor values()

    insert into actor() values()

    and a raft of others.

    None seem to work. Any ideas?

    I don't want to go into detail about how unsafe this is - it is not multi-user compatible and definitely the wrong approach. However, as I can't change the structure, I need to find a solution using the existing tables.

    TIA

  • insert into Actor

    default values

    If you want more than one at at time:

    set nocount on

    insert into Actor

    default values

    go 100

    Will insert 100 rows. Change the 100 to whatever number you want.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • That did it!

    Thanks so much - saved me hours.

  • You're welcome.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply