Reputation: 783
I need to change the data type of a column from nvarchar(50) to nvarchar(MAX). The problem is I already have data in hundreds of rows in this table and I don't want to lose the data.
Is there anyway to change the data type of a column without losing the data in that column?
Upvotes: 1
Views: 1744
Reputation: 755321
Sure - just change it!
ALTER TABLE dbo.YourTable
ALTER COLUMN YourColumnName NVARCHAR(MAX)
This will take some time on a large table with data - but it's definitely not going to destroy any data! After all, you're only extending the size of the column.
OF COURSE: always do this first on a test/dev database, and NEVER do this without having a proper backup in place first!
Upvotes: 3