Solved

Alter table to increase max Len

Posted on 2016-10-25
7
36 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 28

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 48

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 48

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 28

Expert Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard 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.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

792 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