What I'm trying to do is make a copy of a table using a SELECT INTO statement.
After the table is created I want to duplicate the indexes as well.
So the code I'm using is as follows:
SELECT * INTO TableCopy FROM Table
Then:
ALTER TABLE TableCopy ADD CONSTRAINT pkGUID PRIMARY KEY ([GUID])
CREATE INDEX ixIndexName ON TableCopy (CountryCode)
When I execute the index SQL, I get an error that the indexes already exist in the catalog. I didn't think index names had to be unique, I thought they could be duplicated across different tables.
And lo and behold if I create the indexes through management studio, it accepts the index names.
What am I missing here?
Thanks.