Groups | Blog | Home
all groups > sql server (alternate) > august 2003 >

sql server (alternate) : Index name conflict


teddy_theo NO[at]SPAM yahoo.com
8/14/2003 2:18:02 PM
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
sql NO[at]SPAM hayes.ch
8/15/2003 12:42:01 AM
[quoted text, click to view]

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', 'ProductionTable'
exec sp_rename 'ProductionTable.StagingIndexName',
'ProductionIndexName', 'INDEX'
exec sp_rename 'StagingPrimaryKeyName', 'ProductionPrimaryKeyName',
'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.

teddy_theo NO[at]SPAM yahoo.com
8/18/2003 12:44:45 PM
i fixed the problem by creating another database and naming it
AddThis Social Bookmark Button