I am trying to change a column from a varchar(50)
to a nvarchar(200)
. What is the SQL command to alter this table?
354
votes
10 Answers
590
votes
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.
180
votes
13
votes
The syntax to modify a column in an existing table in SQL Server (Transact-SQL) is:
ALTER TABLE table_name
ALTER COLUMN column_name column_type;
For example:
ALTER TABLE employees
ALTER COLUMN last_name VARCHAR(75) NOT NULL;
This SQL Server ALTER TABLE
example will modify the column called last_name
to be a data type of VARCHAR(75)
and force the column to not allow null values.
see here
6
votes
5
votes
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.
1
votes
0
votes