?
Solved

Alter columns collation

Posted on 2011-02-21
2
Medium Priority
?
489 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 1000 total points
ID: 34942647
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 1000 total points
ID: 34943006
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

764 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