Solved

Alter columns collation

Posted on 2011-02-21
2
485 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 250 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 250 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

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.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

726 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