How can we help you today? How can we help you today?

Getting Default instead of GetDate() on insert snipet

Hi,

I'm constantly getting into this annoying issue where my insert script generated by SQL prompt always write DEFAULT instead of the actual default being GetDate().

Some forums posts seems to tell that the GetDate() one should work


Sql prompt version : 10.11.9


Insert script produced

INSERT INTO Question.QuestionnaireType
(
    QuestionnaireTypeId,
    QuestionnaireTypeLabelID,
    CreatedBy,
    CreatedDate
)
VALUES
(   NULL,   -- QuestionnaireTypeId - PrimaryKeyConstant
    NULL,   -- QuestionnaireTypeLabelID - uniqueidentifier
    NULL,   -- CreatedBy - uniqueidentifier
    DEFAULT -- CreatedDate - datetime
    )

Sushi21
0

Comments

1 comment

  • Kurt_M
    Hi @Sushi21

    I did some testing myself on 10.11.11 and this appears to be the intended way the feature works when using the default values. I used your script as a basis and I set up a few other default values on the columns, and you'll notice they all pull through as default, not just the datetime field:




    However, if I change the CreatedDate column to remove the default value and instead add NOT NULL, then it generates GETDATE() in the values section:



    Depending on what way you choose to do it, it doesn't matter too much, as the GETDATE() value will be used when inserting.

    Hope that helps.


    Kurt_M
    0

Add comment

Please sign in to leave a comment.