Click here to Skip to main content
14,603,561 members
Articles » Database » Database » SQL Server » Downloads

SQL Server 2000 Collation Changer

Rate this:
4.88 (99 votes)
Please Sign up or sign in to vote.
4.88 (99 votes)
3 Mar 2008CPOL
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)

Share

About the Author

Alex Baker
Software Developer RXP Services
Australia Australia
No Biography provided

Comments and Discussions

Stats

571.5K views
9.7K downloads
101 bookmarked