Solved

Alter table to increase max Len

Posted on 2016-10-25
7
41 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 49

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 49

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL query for highest sequence 4 64
find SQL job run average duration 24 57
SQL eating up memory? 16 42
user database (login sql or login windows) 3 30
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

726 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