Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2008

    Unanswered: TSQL Windows-1252 to UTF-8 issue

    Hi everyone,
    I have an issue make me sick with Encoding in SQL Server 2000.

    1. I have a database (db1) with tables saved data with Windows-1252 Encoding
    2. Now I want to migrate data from db1 to db2, but I want to store data in db2 is UTF-8. I try to search this similar expriences but found nothing, so, who have this expriences with that can share with me?

    Thanks so much....

  2. #2
    Join Date
    May 2004
    if you need to store unicode strings, use nchar/nvarchar columns instead of char/varchar.

  3. #3
    Join Date
    May 2004
    SQL Server does not support UTF8 character set.
    The facade MS is holding is "if you have multi lingual requirements you should use double byte strings (as in NVARCHAR, NTEXT and NCHAR).

    What can you do?

    First you need to check if you need to support multi lingual data? I most cases there is no such requirement so all you have to do is to create an SQL Server database with a collation that will support the language you need it to store, then move the data trough DTS.

    I hopes this helps,
    In case post additional questions please send me an e-mail to since I do not monitor this thread.


  4. #4
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    UTF-8 is not a data type, it is an encoding standard. UTF-8 can not be handled at the datatype level like INT, DATETIME, and FLOAT can. UTF-8 must be handled by the code that interprets the data.

    Since DB2 is the name for a database engine, I'm going to use the word database for my question.

    Is your problem that you have character data from the 1252 code page stored in Unicode columns in database 1, but you want to store the same data in non-Unicode columns encoded using UTF-8 in database 2?


  5. #5
    Join Date
    Jun 2008

    I solved this problem already

    Hi there,
    Thanks so much for reply to me.

    I am moving data from snitz forum database to new database. My old snitz forum when saving data from website to database used windows-1252 codepage to store data (Of course save in nvarchar and ntext column). My new website save data with Unicode encoded. So, because it's just 140,000 records and I decice to write a very simple application to convert it.

    Here are my sample application

    1. I added more column in destination table: update_status (int), and update it to 0

    2. In my application, I run a script like thist

     public static string iso8859_unicode(string src)
                 Encoding iso = Encoding.GetEncoding("Windows-1252");
                 Encoding unicode = Encoding.UTF8;
                 byte[] isoBytes = iso.GetBytes(src);
                 return unicode.GetString(isoBytes);
      string sql = "select top 1000 * from dbo.tbl_users where update_status=0 order by user_id asc";
                    DataTable dt = ExecuteQuery(sql);
                    foreach (DataRow dr in dt.Rows)
                                          string sql_u = "update tbl_users set update_status=1,User_Full_Name=N'" + iso8859_unicode(dr["User_Full_Name"].ToString()) + "'";
                        sql_u += ",";
                        sql_u += "User_Sign=N'" + iso8859_unicode(dr["User_Sign"].ToString()) + "'";
                                          sql_u += " where user_id=" + dr["user_id"].ToString();
    And less than 1 hour, I convert all my Data. Thanks god it's just 140,000 records...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts