in reply to Using Admin Passwords in Script

Use the facilities provided by the OS.

Preferably

If neither the -U option nor the -P option is specified, sqlcmd tries to connect by using Microsoft Windows Authentication mode.

Otherwise set up a user or group profile for running the script(s) that has the userid & password environment variables (SQLCMDUSER & SQLCMDPASSWORD) set in the profile. Profiles are encrypted.

That way, the scripts can only be run by those authorised to do so by the login id or group membership.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Using Admin Passwords in Script
by OzVegan (Acolyte) on May 20, 2011 at 05:20 UTC

    Thanks guys. Okay, so there are a few options I can try that rely on the agreement of our brand's strict security policies but one will have to work. Either:

    • Create a text file or use the library folder and lock it down to specific users that have SQLServer administrative rights
    • Create a local user and password that has access to run the script and has admin rights to SQLServer

    The Windows Service option didn't work for me. I use Perl scripted Windows Services on one server with INTSRV but in our store environment they only allow SC.EXE to run and it couldn't get it to accept the path to the Perl.exe program and pass it the path to the script at the same time. It just wouldn't work otherwise I'd have Windows Services running.

    Thanks for your help and insights, I have something substantial to work with now :-)