Warm tip: This article is reproduced from stackoverflow.com, please click
sql-server tsql sql-server-2008 type-conversion alter-table

How do you change the datatype of a column in SQL Server?

发布于 2020-03-28 23:16:46

I am trying to change a column from a varchar(50) to a nvarchar(200). What is the SQL command to alter this table?

Questioner
Ascalonian
Viewed
28
906 2017-07-10 20:43
ALTER TABLE TableName 
ALTER COLUMN ColumnName NVARCHAR(200) [NULL | NOT NULL]

EDIT As noted NULL/NOT NULL should have been specified, see Rob's answer as well.