Customer Portal

SQL Server 2008 - DBOutputTable - Autogenerated keys

Comments 3

  • Avatar
    avackova
    0
    Comment actions Permalink
    Hello Dave,
    if the key column is set as an IDENTITY you have to turn of generating the keys, before copying data from one database to another (phase 0 on the picture). Then copy data from one table to another (phase 1). Now you can turn off inserting the identity (phase 2). Loading new data after it, triggers the automatic key generation (phase 3). To make this graph working properly you have to uncheck "Thread-safe connection" box in Advanced properties of target db connection.
    mssqlcopy.png
  • Avatar
    david.oram
    0
    Comment actions Permalink
    Thanks for that, however I realise I didn't really highlight the main issue.

    In your sample, and the online help the DBOutputWriter uses the syntax:

    Insert into table(col1,col2) 
    values ($col1, $col2)
    returning $id:=auto_generated


    This syntax is not acceptable for the SQL Server 2008 database I am using. I checked on wikipedia, and it appears valid for other databases such as Oracle but not SQL Server. Do you know what the equivalent SQL Server syntax is?

    Cheers,
    Dave
  • Avatar
    avackova
    0
    Comment actions Permalink
    Hello Dave,
    the example above I've tested with the MSSQL Server 2008 and it works properly. Do you have MSSQL jdbc specific in your connection definition (jdbcSpecific=MSSQL)? Is one of the columns defined as IDENTITY? Do you get an error?

Please sign in to leave a comment.