Solved

Alter table to increase max Len

Posted on 2016-10-25
7
31 Views
Last Modified: 2016-11-01
My table name = tbl_Students

This table has a column ' Student_TEL1 '      nvarchar(50)

How can I change the max lenght from (50) to (200)? - Without losing DATA

Many thanks
0
Comment
Question by:Abiel de Groot
  • 2
  • 2
7 Comments
 
LVL 24

Accepted Solution

by:
Pawan Kumar earned 250 total points
ID: 41858409
Take backup of your table...


ALTER TABLE [tbl_Students]
ALTER COLUMN [Student_TEL1] NVARCHAR(200)


Then verify the data with the backup.
0
 
LVL 46

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 250 total points
ID: 41858413
Since you're changing for an higher length you won't loose data. Just use ALTER TABLE statement and give the new length for the column:
ALTER TABLE tbl_Students
ALTER COLUMN Student_TEL1 VARCHAR(200);

Open in new window

0
 
LVL 46

Expert Comment

by:Vitor Montalvão
ID: 41858416
Btw, why are you using NVarchar? Do you need Unicode for that column? This will use double of bytes that you'll need for regular Varchar data type.
0
 
LVL 5

Author Comment

by:Abiel de Groot
ID: 41858511
Many thanks. The NvarChar was because of foreign chars.
0
 
LVL 24

Expert Comment

by:Pawan Kumar
ID: 41858547
@Author - Have you tried the code I had given ?
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

920 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

13 Experts available now in Live!

Get 1:1 Help Now