1
votes

When I try to script a table CREATE from a database, it doesn't always script all the columns inside a single CREATE TABLE. Some of the columns will be added via ALTER TABLEs. Why is this? Is SQL server capturing the history of the schema modifications, and any columns added after the initial creation are scripted with ALTERS? The reason this matters is because I'm scripting tables to be used within a VS Database project and it can't handle the ALTER statements.

CREATE TABLE [dbo].[tblPackageType]
(
    [PackageTypeId] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
    [PackageTypeDesc] [varchar](50) NOT NULL
) ON [PRIMARY]
ALTER TABLE [dbo].[tblPackageType] ADD [EDIcode] [varchar](10) NOT NULL
ALTER TABLE [dbo].[tblPackageType] ADD [EDI211] [varchar](10) NULL
1

1 Answers

1
votes

Is SQL server capturing the history of the schema modifications, and any columns added after the initial creation are scripted with ALTERS?

Yes.

If you want to get around this, you can alter the script to be a create including all the needed columns, and after you run it the updated definition will be saved.