3

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.

4
  • May we see the insert statement that causes the difficulty? Commented Jan 29, 2019 at 21:10
  • I'm using an SSIS package destination step. Also, someone posted an answer that solved my problem below Commented Jan 30, 2019 at 14:24
  • I'm not sure why someone would vote to mark this closed . . . Commented Jan 30, 2019 at 14:24
  • There is no insert statement. I'm using SSIS. I am not inserting data into that column. It was supposed to populate the date using the default constraint that I had placed and I didn't understand why it wasn't. Therefore, marking to close the ticket was incorrect. Commented Jan 30, 2019 at 17:11

2 Answers 2

10

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Do not include "ssis_ran_date" column into your insert statement.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.