I am populating a table using an SSIS package.
The idea is that whenever the package uploads to the table, it will timestamp the value using getdate().
My DDL looks like this when I open it up:
CREATE TABLE [REPORTING].[post_ssis_table_1](
[validation_key] [int] IDENTITY(1,1) NOT NULL,
[ssis_ran_date] [datetime] NULL,
[server_name] [varchar](255) NULL,
[data_base] [varchar](255) NULL,
--A bunch of other irrelevant columns
[success_status] [varchar](255) NULL,
[success_criteria] [varchar](255) NULL,
PRIMARY KEY CLUSTERED
(
[validation_key] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [REPORTING].[post_ssis_tbl_1] ADD DEFAULT (getdate()) FOR [ssis_ran_date]
GO
Note: I did not type the alter statement, that's literally what it looks like when I open up the DDL.
Why is the default value not populating for [ssis_ran_date] when I insert rows? It literally just stays null.
If your INSERT statement specifies NULL for a column with a default, then NULL will get inserted.
The default will only be used when that column is not specified in the INSERT at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With