sql-servert-sqltype-conversionalter-table

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


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


Solution

  • 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.