Click here to Skip to main content
15,884,237 members
Articles / Database Development / SQL Server

SQL Server 2000 Collation Changer

Rate me:
Please Sign up or sign in to vote.
4.88/5 (99 votes)
3 Mar 2008CPOL4 min read 635.8K   10.1K   101  
Change collation order for all text columns in a database
using System;
using System.Collections;
using System.Text;
using System.Data.SqlClient;

namespace AlterCollation 
{
    public class ScriptStepCollection : CollectionBase
    {
        public ScriptStep this[int index]
        {
            get { return (ScriptStep)InnerList[index]; }
            set { List[index] = value; }
        }
        public int Add(ScriptStep item)
        {
            if (item == null)
                throw new ArgumentNullException("value");
            return InnerList.Add(item);

        }

        public void Insert(int index, ScriptStep item)
        {
            if (item == null)
                throw new ArgumentNullException("value");
            InnerList.Insert(index, item);
        }

        public int IndexOf(ScriptStep item)
        {
            return InnerList.IndexOf(item);
        }

        public bool Contains(ScriptStep item)
        {
            return InnerList.Contains(item);
        }

        public void Remove(ScriptStep item)
        {
            InnerList.Remove(item);
        }
        public void CopyTo(ScriptStep[] array, int arrayIndex)
        {
            InnerList.CopyTo(array, arrayIndex);
        }
        protected override void OnValidate(object value)
        {
            base.OnValidate(value);
            if (!(value is ScriptStep))
                throw new ArgumentException("Can only add ScriptStep to ScriptStepCollection", "value");
        }

        public void Execute(SqlConnection connection, IScriptExecuteCallback callback)
        {

            if (connection == null) throw new ArgumentNullException("connection");
            if (callback== null) throw new ArgumentNullException("callback");

            int index=0;
            ScriptStep stepToRun;
            callback.ExecutionStarting(this);

            while (index < Count)
            {
                stepToRun = this[index];
                if (!callback.Progress(stepToRun, index + 1, Count)) break;
                stepToRun.Execute(connection, callback);

                index++;
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer RXP Services
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions