Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin.
Search for scripts directly from SSMS, and instantly access any saved scripts in your
SSC briefcase from the favorites tab.
Download now (direct download link)
Thank this author by sharing:
By Steve Pettifer,
This script is designed allow all TEXT, NTEXT, CHAR and VARCHAR columns within a database to be changed en-masse to NVARCHAR. To accomplish this in the simplest way, we must drop all foreign keys, primary keys, indexes, default constraints, unique constraints and check constraints before altering the columns and then recreating all the dropped objects.
The purpose of this script is to generate, based on the system views of a database, all the nescesary DROP, ALTER and CREATE statements for this operation. All keys, indexes etc will be re-created exactly as they were in terms of column order, data sorting direction and so on, and foreign keys will also be re-created WITH NOCHECK if they were previously disabled (as will check constraints, althoguh if check constraints were previously enabled and trusted then a statement will be generated to ensure the constraint is set that way again). Schema names are automatically prepended to appropriate obejct names according to ownership. Indexes, Primary Keys and Unique Constraints will be assigned to theappropriate filegroups automatically.
Apologies if any of the instructions seem a bit noddy - they were originally intended for colleagues who might not be the most fluent SQL developers and I might not have edited them enough!
Gets all columns infos, foreign keys (multicolumn fk handled), referenced primary keys, default and ...
This script reports table columns that allow NULL values but that currently have no NULL values, mak...
A Query to synchronize 2 DB tables, columns, constraints.
This script can convert the usage of bound rule objects in tables to column check constraints
Column and Table Constraints
Constraints can be column constraints or table constraints.A column co...