January 14, 2015 at 2:44 pm
Hi,
I have a index on a column. That index is unique nonclustered index.
After recreate that I want the same name as previous
When I use the script index as drop and create to , it is not giving the same name
January 14, 2015 at 2:57 pm
ramana3327 (1/14/2015)
Hi,I have a index on a column. That index is unique nonclustered index.
After recreate that I want the same name as previous
When I use the script index as drop and create to , it is not giving the same name
The name of an index is not optional in CREATE INDEX, which means that you're using some other method. Please post the code that you're using to drop and create the index.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 14, 2015 at 3:27 pm
I'm with Jeff here. I tried a couple of experiments to see if I could break this. Nothing obvious worked.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 14, 2015 at 3:35 pm
The Index is system generated one.
It gave me below syntax
ALTER TABLE [dbo].[Test] DROP CONSTRAINT [UQ__Test__BED14FEE58EB02C0]
GO
ALTER TABLE [dbo].[Test] ADD UNIQUE NONCLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
January 14, 2015 at 3:49 pm
Modify the syntax so that it includes the name you want:
ALTER TABLE [dbo].Mytable ADD CONSTRAINT xxx UNIQUE NONCLUSTERED
(
[ID] ASC
)
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 14, 2015 at 4:06 pm
Thank you. It is working
January 14, 2015 at 8:38 pm
Good to hear it.
Personal opinion, avoid system generated names. They just make everything harder.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy