Reputation: 773
Is there a way to fully traverse all tables in the database and changing all the varchar
datatype to nvarchar
datatype?
The simple SQL below does not work as intended due to constraints from indexing, unique keys and what not.
ALTER TABLE [CUS].[Customers]
ALTER COLUMN [CustomerNo] NVARCHAR(500);
I tried changing them from SSMS via the GUI way and the profiler actually shows what it does to truly change the datatype.
nvarchar
column changed from varchar
This involves a lot of steps and it is quite cumbersome if I were to do it manually.
Can anyone suggest a more flexible solution to my problem?
Upvotes: 0
Views: 4224
Reputation:
Alternatively you could:
Pros:
Cons:
Depending on the transfer method you choose and size of your tables, the log file might grow huge even if you are in simple recovery mode. This is the worst case scenario when you transfer a lot of data in one huge transaction.
As a side comment: I agree with @Igor - do not change datatype unless you absolutely have to.
Upvotes: 1