Fetch date value from a Table and use it in batch file

  • Hi,

    In my script I use bat file to execute SQL command and then send out a email with all the details.

    I need to read a datetime value from a table and use it in SQL query as a filter and then same value to be passed to batch file for emailing the date value.

    I'm aware of EXIT() comamnd in SQLCMD. But errorlevel variable is capable of holding only integer value i believe. Is there a way by which I can fetch datetime value from a table and pass it to batch file.

    Thanks

    Prathibha

  • I'm not sure if I understand you question but you need to ectract the Datetime value from a column in a table correct?

    If so assign this value to a Global Variable.

    Then use this as a parameter in a Script Task to create the batch file.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • I might have given wrong impression by mentioning word 'Script'.

    In our job we have a .bat file which executes SQL queries using 'SQLCMD' command. so we dont have any script task or anything. Also we are not using DTS or SSIS due to some licensing issue.

    All we have is a master batch file which executes SQL fiels using SQLCMD command. I need to read a datetime column of a table and use it in batch file.

    Sorry for the confusion!

    Thanks

    MLP

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

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