SQL alter column datatype from nvarchar to int
It is possible only when you column has no value or blank. If your column has some value which have nvarchar value and you should try to convert it into int, it will give error.
ALTER TABLE [table_name] ALTER COLUMN [column_name] [data_type]
You can try doing an alter table. If it fails do this:
- Create a new column that's an integer:
ALTER TABLE tableName ADD newCol int;
- Select the data from the old column into the new one:
UPDATE tableName SET newCol = CAST(oldCol AS int)
;
- Drop the old column