Update Column Data Type in SQL Server 2008R2

Posted on 2012-08-29
Last Modified: 2012-08-30
Hi, how do I update Column Data Type in SQL Server 2008R2 using MS SQL Server Management Studio?
The current data type is nvarchar(1), and need to change this to nvarchar(150). Need to change this without losing existing data.
Question by:kris_sk2012
    LVL 25

    Expert Comment

    by:Lee Savidge
    alter table alter column column_name nvarchar(150)
    LVL 25

    Expert Comment

    by:Lee Savidge
    replace table with your table name and then replace column_name with your column name. Do this in SQL Management Studio within the correct database.
    LVL 5

    Expert Comment

    ALTER TABLE dbo.TableName

    sp_help 'Tablename'
    LVL 12

    Expert Comment

    Right click the table the field resides in and select "design", then just edit the data type.

    You'll get an alert window, but you won't lose any data, but it's always a good idea to make a backup before altering the database.
    LVL 9

    Accepted Solution

    ALTER TABLE dbo.YourTable
       ALTER COLUMN YourColumnName nvarchar(150)

    follow steps given in the site
    LVL 25

    Expert Comment

    by:Lee Savidge
    Erm, isn't that what I posted in my comment about an hour before the accepted answer?

    Indeed, isn't this also what VIVEKANANDHAN_PERIASAMY posted in their comment just under an hour before the accepted answer?

     Jared_S also posted an equally valid method using the interface rather than using code just a few minutes later way before the accepted anwer.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
         When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    761 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

    14 Experts available now in Live!

    Get 1:1 Help Now