Solved

Alter table to increase max Len

Posted on 2016-10-25
7
44 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 50

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 50

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

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.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.

728 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