Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the SQL to change the field length of a table column in SQL Server

Tags:

sql

sql-server

What is the SQL to make a field go from nvarchar(50) to nvarchar(250)?

When I try to change it through the SQL Server Management Studio, it doesn't allow me to do it, so I figured I would try SQL directly instead of using the GUI.

like image 697
leora Avatar asked Sep 06 '25 15:09

leora


2 Answers

Alter table tblname ALTER Column colname nvarchar(250) [NOT] NULL

If NULL / NOT NULL is not specified the column will become Nullable irrespective of what ever the original specification was.

like image 171
Martin Smith Avatar answered Sep 09 '25 16:09

Martin Smith


ALTER TABLE MyTable
ALTER COLUMN MyColumn varchar(NewSize)
like image 27
Randy Minder Avatar answered Sep 09 '25 15:09

Randy Minder