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?teddy_theo@.yahoo.com (Ted Theodoropoulos) wrote in message news:<f5682868.0308141318.7b16a1db@.posting.google.com>...
> 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?
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.
Simon|||i fixed the problem by creating another database and naming it
[dbname]_staging. not very elegant but it works.
No comments:
Post a Comment