Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2006
    Posts
    115

    Unanswered: SQLCMD - how do I pass parameter at dos command line to input file?

    I am not sure if this has been asked before but I couldn't find any thread talking about this.

    Let's say we have a parameter in the .sql input file called @Start_Date, how can we pass the value of a particular date, for example, "02-28-2007" to @Start_Date via SQLCMD? is it possible?

    I'm trying to skip the need to write a simple windows application...if things can be achieved via dos command line, that will keep everything simple!

    thanks!

  2. #2
    Join Date
    Mar 2007
    Location
    Holmestrand, Norway
    Posts
    332
    If you had checked sqlcmd -? you would have noted the -v option, that you are looking for.
    Ole Kristian Velstadbråten Bangås - Virinco - MSSQL.no - Facebook - Twitter

  3. #3
    Join Date
    Oct 2006
    Posts
    115
    manage to get it done through -v and SET /P option

  4. #4
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    you can also write sql scripts that reference environment variables, and sqlcmd will replace the env vars appropriately when it invokes the script. I use this a lot and it's a lifesaver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •