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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Alter Index - Primary key modified (made composite

Author  Topic 

aambasta
Starting Member

2 Posts

Posted - 2009-07-27 : 06:41:34
I need to alter index (named I_TMP_PROFILE_EVENT_ORDER_ID associated with table TMP_PROFILE_EVENT_ORDERING_T) and rebuild it.

This index currently have one column OBJ_ID0 which is also the primary key for this index, now I need to add one more column to this index i.e., REC_ID and make a composite primary key which includes both columns.

I am suppose to use Alter Index command.

Please help I am newbie in sql.

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-07-27 : 07:16:49
Search in BOL (Books Online - SQLs help file) for ALTER INDEX. Here you will find the syntax and some examples. From there you can quite easily work out what you need.
Go to Top of Page

ayamas
Aged Yak Warrior

552 Posts

Posted - 2009-07-27 : 07:20:56
quote:
Originally posted by aambasta

I need to alter index (named I_TMP_PROFILE_EVENT_ORDER_ID associated with table TMP_PROFILE_EVENT_ORDERING_T) and rebuild it.

This index currently have one column OBJ_ID0 which is also the primary key for this index, now I need to add one more column to this index i.e., REC_ID and make a composite primary key which includes both columns.

I am suppose to use Alter Index command.

Please help I am newbie in sql.



Cant you use SSMS??
Go to Top of Page

aambasta
Starting Member

2 Posts

Posted - 2009-07-27 : 07:25:09
No I cannot use SSMS or any other tool, I am only allowed to do this using SQL Command (Alter Index).
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-07-27 : 07:29:10
quote:
Originally posted by ayamas

Cant you use SSMS??


I would guess that he is a student and has been tasked with doing this in a particular way.

See my reply above.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2009-07-27 : 08:07:31
As far as I'm aware, you can't use ALTER INDEX to add a column to the index, you have to drop the index and recreate it. For the PK constraint, that means dropping the constraint (ALTER TABLE) and then recreating the constraint

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -