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 2008 Forums
 Transact-SQL (2008)
 Script a collation change when index present?

Author  Topic 

303factory
Starting Member

2 Posts

Posted - 2011-09-15 : 11:18:58
Hi peeps I'm a bit stuck

I need to script a change to a column in a table so it is case sensitive. The following SQL should be able to do it

ALTER TABLE myTable
ALTER COLUMN myColumn CHAR(2)
COLLATE Latin1_General_CS_AS

However i get an error saying

'The index 'IX_mytable' is dependent on column 'myColumn'

I'm assuming I also need some syntax to change the collation in the index but have no idea how to go about doing so. Can anyone help wiht this?

303

Kristen
Test

22859 Posts

Posted - 2011-09-15 : 11:26:58
I think you just need to Drop the index, run your ALTER, and then Re-create the index

You should be able to script the existing index in SSMS.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-15 : 11:27:53
nope. you need to drop the index prior to altering and recreate it afterwards

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

303factory
Starting Member

2 Posts

Posted - 2011-09-15 : 11:44:27
quote:
Originally posted by Kristen

I think you just need to Drop the index, run your ALTER, and then Re-create the index

You should be able to script the existing index in SSMS.



Thank you kindly!
Go to Top of Page
   

- Advertisement -