resetting Identity column values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iitt2007
    New Member
    • Feb 2008
    • 13

    resetting Identity column values

    I have a table :
    drop table REPORTING_FILES
    Create table REPORTING_FILES
    (
    DRF_FILE_ID INTEGER IDENTITY (1,1) PRIMARY KEY,
    DRF_FILE_NAME VARCHAR(50),
    DRF_SUBJECT_LIN E varchar(50)
    )

    With entries :
    1 abc abc subject
    2 xyz xyz subject
    3 mnq mnq subject
    4 yyz yyz subject

    When I delete DRF_FILE_ID=2 , I have entry like
    1 abc abc subject
    3 mnq mnq subject
    4 yyz yyz subject

    I would like to have it as :
    1 abc abc subject
    2 mnq mnq subject
    3 yyz yyz subject

    How can I achive this?
    I have to reset this as by drop down list in .NET applcation uses the Index to display and delete the file, since index 2 is deleted, and not rearranged, its creating a problem.
    Thanks.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by iitt2007
    I have a table :
    drop table REPORTING_FILES
    Create table REPORTING_FILES
    (
    DRF_FILE_ID INTEGER IDENTITY (1,1) PRIMARY KEY,
    DRF_FILE_NAME VARCHAR(50),
    DRF_SUBJECT_LIN E varchar(50)
    )

    With entries :
    1 abc abc subject
    2 xyz xyz subject
    3 mnq mnq subject
    4 yyz yyz subject

    When I delete DRF_FILE_ID=2 , I have entry like
    1 abc abc subject
    3 mnq mnq subject
    4 yyz yyz subject

    I would like to have it as :
    1 abc abc subject
    2 mnq mnq subject
    3 yyz yyz subject

    How can I achive this?
    I have to reset this as by drop down list in .NET applcation uses the Index to display and delete the file, since index 2 is deleted, and not rearranged, its creating a problem.
    Thanks.
    if there are other relationship that this field is being used for, you're going to reset all of those. If you just want a dynamic row you can generate it dynamically using a sql just like this If you really want this column reset, check it here

    -- CK

    -- CK

    Comment

    Working...