---
title: "How to change the length or attributes of an existing column using SQL?"  
description: "How to change the length or attributes of an existing column using SQL?"  
author: "Utpal Vishwas"  
published: 2023-08-30  
updated: 2023-08-31  
canonical: https://www.mindstick.com/forum/159780/how-to-change-the-length-or-attributes-of-an-existing-column-using-sql  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 2 minutes  

---

# How to change the length or attributes of an existing column using SQL?

How to change the [length](https://www.mindstick.com/interview/1915/what-is-the-difference-between-char_length-and-length) or [attributes](https://www.mindstick.com/articles/13105/2-attributes-that-make-your-odoo-ecommerce-theme-productive-and-engaging) of an existing [column](https://www.mindstick.com/forum/33860/how-to-calculate-column-summary-in-sql-server) using [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database)?

## Replies

### Reply by Aryan Kumar

To change the length or attributes of an existing column using SQL, you can use the `ALTER TABLE` statement. The syntax for this statement is as follows:

SQL

```plaintext
ALTER TABLE table_name
MODIFY COLUMN column_name new_data_type [(new_length)] [NULL | NOT NULL];
```

For example, to change the length of the `Name` column in the `Customers` table to 50 characters, you would use the following statement:

SQL

```plaintext
ALTER TABLE Customers
MODIFY COLUMN Name VARCHAR(50);
```

You can also use the `ALTER TABLE` statement to change other attributes of a column, such as its data type, whether it is nullable, and whether it has a default value.

**Note:** When you change the length of a column, you must make sure that the existing data in the column can be stored in the new size. If the data is larger than the new size, you will need to update the data before you can change the column length.

Here are some additional things to keep in mind when changing the length or attributes of an existing column:

- You cannot change the name of an existing column.
- You cannot change the data type of a column if there is data in the column.
- If you change the data type of a column, the existing data in the column may be truncated or converted to the new data type.
- If you change the nullability of a column, the existing data in the column may be changed to NULL.


---

Original Source: https://www.mindstick.com/forum/159780/how-to-change-the-length-or-attributes-of-an-existing-column-using-sql

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
