Search code examples
sql-serverssmsssms-2014

How to avoid ALTER TABLE XXX ADD YYY statements in files generated by SSMS?


I need to generate an SQL script from my MS SQL Server database. In that end, I used the "Generate scripts..." tool provided by SQL Server Management, which worked.

However for one single table, some of the fields are not included in the CREATE TABLE statement. Some of them are added afterwards using ALTER TABLE XXX ADD YYY statements.

How can I ensure that all the fields are included in the CREATE TABLE statements ?


Solution

  • Most likely there is a SET statement before the ALTER TABLE statements appear. In most cases this is caused by changing the ANSI_PADDING when adding columns. Now I'm just guessing, but can you share what SSMS generates for that table?

    Something similar: SSMS "create table" sometimes scripts defaults inline, sometimes separately