I need to change datatype of all columns in database where datatype is char(255) to nvarchar(255). To do that, I need to remove P/F keys and then recreate them again. But on datatype change, I loose not null information.
Some columns may be nullable, and some not. This is the problem.
How can I solve it?
EDIT:
When I drop P/F keys, I try to change datatype successfully. And then, when recreating keys it says that cannot set key on that field because it is nullable.
Then I tried to do it with try/catch:
try to add key, and if not, change datatype with not null, and try again adding key.
It works, but now throws tons of some exception. I think the job is done, but I am not sure because my DB has about 100 tables and cannt check all of them if they are ok.
So is here some other way to do this?