Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    4

    Unanswered: Counter settings?

    I'm changing databases for a website from Access to SQl Server.
    In the Access file, the ID column is assign as 'counter' so the value is automaticly raised by 1 when 'Insert'-statement is used.
    How is the equivalent made for SQL Server?
    I get an error message when I use the 'Insert statement'

    Thanks
    Calle

  2. #2
    Join Date
    Sep 2003
    Posts
    2

    Re: Counter settings?

    Originally posted by Calle
    I'm changing databases for a website from Access to SQl Server.
    In the Access file, the ID column is assign as 'counter' so the value is automaticly raised by 1 when 'Insert'-statement is used.
    How is the equivalent made for SQL Server?
    I get an error message when I use the 'Insert statement'

    Thanks
    Calle
    Try changing your ID column to an integer and set the Identity property to Yes (not for replication), set seed to 1 and increment to 1.

    This is the same as the Autonumber function in Access.

  3. #3
    Join Date
    Sep 2003
    Posts
    522
    I think this has already been done. actually this is the reason for the error. you can remove identity property on the target table and do your insert. once it completes you can reestablish identity(1,1). another way would be to set identity_insert your_table_name on before the insert, and then set it off after insert completes. third way would be to exclude the identity field from being populated. but the last method would assign brand new identity values which may break relationship between tables.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •