How to remove Scripting variables not defined in sqlcmd

  • Whizkid

    Right there with Babe

    Points: 783

    I've been executing the SQL script in sqlcmd and it has more arguments.

    Is there any possibility to declare some of the arguments as optional, If user fails to enter value for any of the arguments then it displays the following message.

    **

    'inputvar1' scripting variable not defined

    'inputvar2' scripting variable not defined

    'inputvar3' scripting variable not defined

    **

    And, the following statement get printed along with above message

    Changed database context to 'testdb'

    I need to remove these messages while getting printed in output file.

    Please help me on t

  • Whizkid

    Right there with Babe

    Points: 783

    Can anyone help me on this?

  • g.britton

    SSChampion

    Points: 13689

    are you explicitly defining the variables by using the :Setvar command?

    Gerald Britton, MCSE-DP, MVPToronto PASS Chapter[/url]

  • Whizkid

    Right there with Babe

    Points: 783

    No, I'm just passing arguments by using -v inputvar1="abc" inputvar2="xyz".

    Here, user may pass argument called "inputvar3". If user fails to enter "inputvar3" then it's printing the message like 'inputvar3' scripting variable not defined

    I don't want to print the message like if fails to pass arguments "inputvar3"

  • dsacker

    Newbie

    Points: 1

    I know I'm coming along late on this thread, but you can use the following:

    SQLCMD -S YourServer -E -d YourDatabase -i YourScript 2> nul

    That will send the StdErrorOut to the bit bucket.

  • KerryBrown

    Newbie

    Points: 1

    dsacker wrote:

    I know I'm coming along late on this thread, but you can use the following:

    SQLCMD -S YourServer -E -d YourDatabase -i YourScript 2> nul

    That will send the StdErrorOut to the bit bucket.

     

    I am facing the similar issue and i will follow the mentioned instructions and update you here. Thank you for your help

    Product Reviews: https://www.reviewsed.com/

Viewing 6 posts - 1 through 6 (of 6 total)

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