Results 1 to 4 of 4
  1. #1
    Join Date
    May 2012
    Posts
    2

    Unanswered: power shell script or windows batch file for sql server

    Could someone please provide me the powershell script for the below query.
    i have two text files,
    one file contains the list of SQL server's and another file have few sql queries.
    i am looking for a powershell script or windows batch file that pick up the server name from first file and run the sql commands which is in 2nd text file and keep the output in seperate text file.

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Powershell will be more useful to you in the long run, but....
    Code:
    for /f %a in (servers.txt) do sqlcmd /E /S%a /iscript.txt /o%aoutput.txt

  3. #3
    Join Date
    May 2012
    Posts
    2
    is that single line will takes care everything

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Well, it does a lot, but I would not wait for it to make me a cup of coffee. Have you tested it?

Posting Permissions

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