Dynamically populating variable value not working

  • I am trying to populate variable value dynamically as follows but it is not working.

    SELECT ISNULL(MAX(ModifiedDate), '') MaxModifiedDate

    FROM [DB1] WITH (NOLOCK)

    MaxModifiedDate is a variable name

    I have set a breakpoint after this task and when I check the value it is showing '1/1/1900'

    Any ideas?

    Thanks.

  • Someone had deleted the data from test DB1, so I was seeing no data in variable. But as soon as I populated data in the table, it shows up in the variable.

  • Are you doing this in Execute SQL Task ?? If yes then this is not the correct eway to assign value to the variable. If no then give a bit more over how you are performing your task.

    Try to google for setting variable value from execute sql task. You will get lot of article on that. If not let me know.

    __________________________________________
    ---------------------------------------------------
    Save our mother Earth. Go Green !!!

  • Slightly off-topic, but why are you using the WITH(NOLOCK) query hint?

    You do realize it can give you incorrect results?

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply