Well, it's not that easy as you mentioned in the above algorithm. Remember some lines have DEFAULT, etc. I did the work manually and my wrist hurts now!! For the record, what I did:- Generated script for all tables - Prepared some templates like:ALTER TABLE [schema].[TableName] ADD DEFAULT Def1 FOR [Field1], DEFAULT Def2 FOR [Field2]/*****************************************/ALTER TABLE [schema].[TableName] WITH NOCHECK ADD CONSTRAINT [PK_Indices] PRIMARY KEY NONCLUSTERED ( [FieldX] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
Then all I had to do was to copy from the tables script and replace the red part in above templates and execute. And repeate for all tables.- Finally, ran the PK/FK scripts which already was generated for the tables. Canada DBA