Need simple way to convert all nchar to nvarchar

Posted on 2011-04-21
Last Modified: 2012-05-11
I am trying to change all of my fields on the database that are of type "nchar" to "nvarchar", but I'm finding this a much more difficult task than I thought it would be--unless I'm just missing something.   I am able to get all of my nchar fields, but many of them are tied to indexes, so when I run my conversion, it errors on any field that has an index tied to it.

Is there a way I could convert these fields easily to nvarchar and make sure the indexes are put back intact once it's done converting the fields without having to do them one by one?   That could take forever.

And in case you're wondering, there is good reason for the conversion to nvarchar, needless to say, space.
Question by:saturation
    LVL 32

    Expert Comment


    Have you thought of scripting the database,
    Changing the datatypes in the script and recreating the database then just import data from the old database
    LVL 7

    Expert Comment

    If you don't want to script the entire thing out like @ewangoya mentioned script it out.

    Right click on the database. Tasks->Generate Scripts. On the selection screen make sure that CREATE is set to "true" and that "Script (Full Text)Indexes" is set to "true". Then select the tables you want to generate the indexes for.

    Do a find/replace for "CREATE INDEX" to "DROP INDEX". Run the drops. Make your alter statement changes and the undo the DROP INDEX and run the creates
    LVL 42

    Accepted Solution

    you can script your table
    create as a new named with nvarchar adjustments
     pump data from old table to new one
    insert into new
    select * from old one

    add from old table constrains indexes

    or try to check what is your clusterd index and what constrains have this field
    script them for create

    and drop (as per earlier posts) change datatype
    and add these indexes constrains back

    --use below system procs to see what your table has
    sp_helpindex yourtablename
    sp_help  yourtablename


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
    Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now