I am trying to change a column from a varchar(50)
to a nvarchar(200)
. What is the SQL command to alter this table?
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.
Don't forget nullability.
ALTER TABLE <schemaName>.<tableName>
ALTER COLUMN <columnName> nvarchar(200) [NULL|NOT NULL]
As long as you're increasing the size of your varchar you're OK. As per the Alter Table reference:
Reducing the precision or scale of a column may cause data truncation.
Try this:
ALTER TABLE "table_name"
MODIFY "column_name" "New Data Type";
Use the Alter table statement.
Alter table TableName Alter Column ColumnName nvarchar(100)
ALTER TABLE [dbo].[TableName]
ALTER COLUMN ColumnName VARCHAR(Max) NULL