SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 script start up accounts
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mherfkens
Starting Member

8 Posts

Posted - 02/17/2004 :  18:54:01  Show Profile  Visit mherfkens's Homepage  Reply with Quote
Is it possible to write a T-SQL scripts to change the accounts that run the SQLExec service and the SQL Agent service? If so how?

tkizer
Almighty SQL Goddess

USA
37287 Posts

Posted - 02/17/2004 :  18:58:28  Show Profile  Visit tkizer's Homepage  Reply with Quote
If you can do it from a cmd window using a DOS command, then you can use xp_cmdshell to make the change using T-SQL. xp_cmdshell can run any DOS command. You'll need sysadmin privileges to run the extended stored procedure. Here is an example of its use:

EXEC master.dbo.xp_cmdshell 'DIR C:\Temp\'

Tara
Go to Top of Page

claire
Starting Member

USA
19 Posts

Posted - 02/25/2004 :  10:44:59  Show Profile  Reply with Quote
Not exactly, xp_cmdshell is not so powerful as Command prompt. Like Calc.exe, you could call from commnand prompt, but wont work in xp_cmdshell
Go to Top of Page

mherfkens
Starting Member

8 Posts

Posted - 02/25/2004 :  11:04:15  Show Profile  Visit mherfkens's Homepage  Reply with Quote
So Claire, what is your suggested method?
Go to Top of Page

ditch
Flowing Fount of Yak Knowledge

South Africa
1466 Posts

Posted - 02/25/2004 :  12:01:56  Show Profile  Visit ditch's Homepage  Reply with Quote
quote:
Originally posted by claire

Not exactly, xp_cmdshell is not so powerful as Command prompt. Like Calc.exe, you could call from commnand prompt, but wont work in xp_cmdshell



I'm not sure why someone would want to do this though.


Duane.
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
37287 Posts

Posted - 02/25/2004 :  12:19:23  Show Profile  Visit tkizer's Homepage  Reply with Quote
quote:
Originally posted by claire

Not exactly, xp_cmdshell is not so powerful as Command prompt. Like Calc.exe, you could call from commnand prompt, but wont work in xp_cmdshell



I'm not sure what the point of calling calc.exe from xp_cmdshell would be.


mherfkens, use xp_cmdshell for this. It's the only way with T-SQL to do what you want. You just need to figure out which cmd commands you'll need.

Tara
Go to Top of Page

mherfkens
Starting Member

8 Posts

Posted - 02/25/2004 :  12:25:37  Show Profile  Visit mherfkens's Homepage  Reply with Quote
Well I most definately don't want to open calc, I just want to move some files or kick off a batch file. After the post from Tara I set ip up to start the SQL Agent, it works great.

I just need to finish creating a script that I can give to domain admins to run on SQL Servers that will grant me access and if I can figure out all the details I'd like it to set up jobs for each existing database. I'm just not doing so well scripting it to pull the database names from the system tables and create jobs for all the user databases.
Go to Top of Page

claire
Starting Member

USA
19 Posts

Posted - 02/25/2004 :  13:20:44  Show Profile  Reply with Quote
It's nothing about the point. But just keep the concept that T-SQL xp_cmdshell cannot be treated the same as command prompt.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.19 seconds. Powered By: Snitz Forums 2000