Friday, February 24, 2012

Can I start Excel on a PC using a Stored Procedure?

Is there any way to have a job in SQL Server start Excel on a PC?
Thanks in advance,
RaulExcel is a desktop application. You cannot start applications that require
a GUI component from SQL Server... SQL Server Agent will hang.
What exactly are you trying to accomplish?
"Raul" <raul@.nothere.com> wrote in message
news:62AA65E5-C7A4-4B81-9BFC-5A1AC579BE42@.microsoft.com...
> Is there any way to have a job in SQL Server start Excel on a PC?
> Thanks in advance,
> Raul|||You could create a scheduled task on your PC, called Task1, which launches
Excel.
From the SQL server,
xp_cmdshell 'schtasks /run /tn Task1 /s NAMEOFPC'
In order for this to work the SQL server process must be running as a user
that has administrative authority on the PC on which you want to start Excel
.
(Starting a scheduled task remotely requires administrator priveledge). If i
t
is running under the local system account, you could specify a username and
password in the schtasks command:
xp_cmdshell 'schtasks /run /tn Task1 /s NAMEOFPC /u username /p password'
This way would put the password for an (administrative) account in plain
text somewhere, so it is not very secure.
"Raul" wrote:

> Is there any way to have a job in SQL Server start Excel on a PC?
> Thanks in advance,
> Raul|||I want a stored procedure, that is run as a scheduled job in SQL Server
Agent, to return the results of a query to a specific Excel workbook. Once
the data is inserted in the workbook, I would like to run a VBA routine in
the workbook to carry out a number of tasks.
I can write the results of the query in Excel using a linked server to the
desired spreadsheet, but I like to be able to fire off the routine to perfor
m
a number of desired tasks after the data has been inserted.
Raul
"Aaron Bertrand [SQL Server MVP]" wrote:

> Excel is a desktop application. You cannot start applications that requir
e
> a GUI component from SQL Server... SQL Server Agent will hang.
> What exactly are you trying to accomplish?
>
>
>
> "Raul" <raul@.nothere.com> wrote in message
> news:62AA65E5-C7A4-4B81-9BFC-5A1AC579BE42@.microsoft.com...
>
>|||Thanks a bunch! The biggest problem may be getting the IT folks to give me
administrator privileges on the server. I guess the other option is to add
a
new administrator account on my PC.
Thanks again,
Raul
"Mark Williams" wrote:
> You could create a scheduled task on your PC, called Task1, which launches
> Excel.
> From the SQL server,
> xp_cmdshell 'schtasks /run /tn Task1 /s NAMEOFPC'
> In order for this to work the SQL server process must be running as a user
> that has administrative authority on the PC on which you want to start Exc
el.
> (Starting a scheduled task remotely requires administrator priveledge). If
it
> is running under the local system account, you could specify a username an
d
> password in the schtasks command:
> xp_cmdshell 'schtasks /run /tn Task1 /s NAMEOFPC /u username /p password'
> This way would put the password for an (administrative) account in plain
> text somewhere, so it is not very secure.
> --
> "Raul" wrote:
>

No comments:

Post a Comment