SMO generating DDL for (initial) tables and then ALTER statements to add more columns to it ?
Why is SMO generating DDL for (initial) tables and then ALTER statements to add more columns to it ?
This gets exec ddl errors for tables that initially had no *char(Max) or text cols.
SQLHelp #sqlbug #SSMS 18.2
The bug is caused by the fact someone messed with the ANSI_PADDING and used different settings when creating the table and adding columns to it!
I have performed the script step by step on as well SQL2008R2 as on an Azure Managed Instance.
Both generate that script flaw.
Remarkably it starts generating the "add column" as soon as you perform the first "alter table add column ...".
Why does it not just generate the full "create table" in a single command ?
Off course the bug only arrises when you add a LOB column.
Then it generates a create table statement including the "TEXTIMAGE_ON"-part.
That causes the "create table" to fail as at that time the table does not have LOB columns and you are not allowed to use that part of the clause in the ddl.