Solved

Alter table to increase max Len

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

Accepted Solution

by:
Pawan Kumar Khowal 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 45

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 45

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 17

Expert Comment

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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

708 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

17 Experts available now in Live!

Get 1:1 Help Now