Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mmkrishna1919
Yak Posting Veteran
95 Posts |
Posted - 2012-10-19 : 07:37:53
|
Hi All,If we create an primary key on a table column automatically an clustered index will create with the name of primary key constraint name.is it possible to give separate name for the automatically created index?if yes Please advise the sample syntax.Thanks..M.MURALI kRISHNA |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2012-10-19 : 17:08:45
|
[CODE]create table MyTable ( MyPKColumn int CONSTRAINT PK_MyTable PRIMARY KEY not null )[/CODE]=================================================We are far more concerned about the desecration of the flag than we are about the desecration of our land. -Wendell Berry |
|
|
mmkrishna1919
Yak Posting Veteran
95 Posts |
Posted - 2012-10-22 : 01:36:25
|
Hi Bustaz Kool,The above syntax(what you mentioned)will create a clustered index with the name "PK_MyTable" automatically.But my requirement is need to create a clustered index with some other name like "IX_PK_mypkcolumn"(overwrite the automatic naming of index).Thanks.M.MURALI kRISHNA |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2012-10-22 : 03:40:24
|
I don't think it's possible to change the default naming scheme. If you are determined to have custom names you should create the table/pk/index manually.- LumbagoMy blog-> http://thefirstsql.com |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2012-10-22 : 19:54:12
|
Can't you use: [CODE]create table MyTable ( MyPKColumn int CONSTRAINT IX_PK_mypkcolumn PRIMARY KEY not null )[/CODE]My point being that you can explicitly name the index which would overwrite the default name. If you omit the keyword "CONSTRAINT" and the explicit name and just specify "PRIMARY KEY" you'll get the default name.=================================================We are far more concerned about the desecration of the flag than we are about the desecration of our land. -Wendell Berry |
|
|
|
|
|