Solved

Alter columns collation

Posted on 2011-02-21
2
481 Views
Last Modified: 2012-05-11
Hi Folks

I'm trying to write an upgrade script to fix collation problems.

When I run this:

alter table AccountingPeriodSetDesc alter column AccountingPeriodSet collate SQL_Latin1_General_CP1_CI_AS

I get this:

Server: Msg 5074, Level 16, State 8, Line 1
The index 'indAccountingPeriodSetDe00001' is dependent on column 'AccountingPeriodSetDesc'.
Server: Msg 4922, Level 16, State 1, Line 1
ALTER TABLE ALTER COLUMN AccountingPeriodSetDesc failed because one or more objects access this column.

However, when I do the change manually in SSMS, the system is clever enough to update all the tables so the DRI exists before and after, and the change is still made.

Is there a way to programmatically do this without having to recode what all the indexes and fk's etc are ? The solution must be a stable, simple system, not a great big script that might fail because the programmer forgot about a certain type of constraint ! So ideally access to the same API that SSMS uses to make these edits seemlessly - is there such as capability ? SMO or whatever ??

thanks
Paul




0
Comment
Question by:plq
2 Comments
 
LVL 25

Accepted Solution

by:
Shaun Kline earned 250 total points
Comment Utility
When making changes to a database object, SSMS has an option to generate the SQL script. This should include all actions that SQL Server is taking. It would be a good starting point for determining your best course of action.
0
 
LVL 26

Assisted Solution

by:tigin44
tigin44 earned 250 total points
Comment Utility
get the create script of the index indAccountingPeriodSetDe00001

drop index AccountingPeriodSetDesc.indAccountingPeriodSetDe00001
alter table AccountingPeriodSetDesc alter column AccountingPeriodSet collate SQL_Latin1_General_CP1_CI_AS

recrerate the index by using the script that you get
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now