Need to run a script using the SA logon

  • I run scripts in Query Analyzer for our consultant. The instructions say to make sure to login as SA. My logon to SQL is a system admin but I guess that is not enough to run the script. How do I logon as the SA on the db to run the scripts on the db?

    I'm sure this is a simple thing.

    Thanks so much in advance.

  • Actually SA is a SysAdmin account created at the time of installing SQL Server. Do you know the password for that user SA? If so, Open SSMS (In SQL 2005) or Query Analyzer (SQL 2000) Change the Authentication method from Windows Authentication to SQL Authentication. Enter SA as the user and the password of SA and connect. Once connected, the rest you can do it as you were doing before.

    Even though you are a SysAdmin in Windows Domain, you might not have sys admin privileges in SQL Server DB. This happens when BUILDIN/Administrator group has been dropped from the SQL Server.

    I hope this helped you.

    -Roy

  • Hi

    What is that script that is asking for SA log in to run, 😉

  • Thanks Roy, I have SQL 2000. Good info! I have QA already opened then I clicked on file then "connect" then entered in the SA logon id and password. Then I had to make sure that I selected SA from the object browser drop down instead of my network logon and of course make sure I'm in the correct db. Hope that was how to do it.

    Crazyman, it is a script to fix an error in our accounting db. The script will not commit changes, it just creates a test for the fix. If the script can run, we will be able to see what the changes look like before we commit them. I do understand very much that things should not normally be run using the sa logon, but I don't write the scripts, I just run them! 🙂

  • Yes Kash... Thats what you had to do...

    I hope things work out with the issues.

    -Roy

  • Thanks Roy, there seems to be a problem with the script as it says it cannot continue due to not having a valid account to the db. Strange because the instructions say to log on as the sa... Well for now, it's going back to the script writer for further instructions. I'm glad at least the problem is not on my side. 🙂

  • That is strange...If you are able to connect with SA, that means that the account exists. So this must be some other issue....

    -Roy

  • Sounds to me like the test script is trying to alter some other account's login / permissions information. That might be why it needed SA access. Of course, the account in question isn't on your DB (or the script writer forgot to throw a USE &ltDatabase&gt statement in the script).

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

Viewing 8 posts - 1 through 7 (of 7 total)

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