Index name conflict

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ted Theodoropoulos

    Index name conflict

    i have a dts package that is going to run at night and pull data from
    2 tables in an Oracle db and load it to 2 staging tables that my
    package creates in sql server 2000. i then execute a few sprocs to
    and columns, indexes, etc. after that all happens successfully i want
    to delete the two production tables and rename the staging tables to
    take their place.

    the problem is that when i run the sproc to add the indexes,
    constraints, etc i get an error because objects with the same name
    exist on the 2 production tables. i can't delete the production
    tables until the very last step. i thought about generating a random
    number in my sproc and using it as the name of the index but that
    seems crude and messy. any ideas?
  • Simon Hayes

    #2
    Re: Index name conflict

    teddy_theo@yaho o.com (Ted Theodoropoulos) wrote in message news:<f5682868. 0308141318.7b16 a1db@posting.go ogle.com>...[color=blue]
    > i have a dts package that is going to run at night and pull data from
    > 2 tables in an Oracle db and load it to 2 staging tables that my
    > package creates in sql server 2000. i then execute a few sprocs to
    > and columns, indexes, etc. after that all happens successfully i want
    > to delete the two production tables and rename the staging tables to
    > take their place.
    >
    > the problem is that when i run the sproc to add the indexes,
    > constraints, etc i get an error because objects with the same name
    > exist on the 2 production tables. i can't delete the production
    > tables until the very last step. i thought about generating a random
    > number in my sproc and using it as the name of the index but that
    > seems crude and messy. any ideas?[/color]

    It's not entirely clear from your email what your process is, but you
    could use one set of names for the constraints etc. when they're on
    the staging tables, then rename them after you rename the tables:

    exec sp_rename 'StagingTable', 'ProductionTabl e'
    exec sp_rename 'ProductionTabl e.StagingIndexN ame',
    'ProductionInde xName', 'INDEX'
    exec sp_rename 'StagingPrimary KeyName', 'ProductionPrim aryKeyName',
    'OBJECT'
    etc.

    If this isn't helpful, perhaps you could clarify the order of events
    in your process, and give an example of where the names clash.

    Simon

    Comment

    • Ted Theodoropoulos

      #3
      Re: Index name conflict

      i fixed the problem by creating another database and naming it
      [dbname]_staging. not very elegant but it works.

      Comment

      Working...