SQL Server 2005 MSDB Access

SQL Server 2005 MSDB Access

am 15.04.2008 17:18:19 von cappjr

On my SQL Server, I have a stored proc called 'sp_exec_job' that
simply starts a job:

EXEC [msdb].[dbo].sp_start.job @JOB_NAME

When I run this from Management Studio, it works fine. Yea.

But, when I try to execute sp_exec_job from my .NET (C#) code (on the
same server as the SQL DB), I get the following error:

System.Data.SqlClient.SqlException: Could not find server 'msdb' in
sysservers. Execute sp_addlinkedserver to add the server to
sysservers.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlExcep tion
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(Tds ParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)

Any ideas?

Re: SQL Server 2005 MSDB Access

am 15.04.2008 17:20:03 von cappjr

Sorry, the above message is not correct (I pasted the wrong message).
This is the error I am getting...

System.Data.SqlClient.SqlException: EXECUTE permission denied on
object 'sp_start_job', database 'msdb', schema 'dbo'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlExcep tion
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(Tds ParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)

Re: SQL Server 2005 MSDB Access

am 15.04.2008 17:22:51 von cappjr

On Apr 15, 10:20=A0am, cap...@gmail.com wrote:
> Sorry, the above message is not correct (I pasted the wrong message).
> This is the error I am getting...
>
> System.Data.SqlClient.SqlException: EXECUTE permission denied on
> object 'sp_start_job', database 'msdb', schema 'dbo'.
> at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
> Boolean breakConnection)
> at System.Data.SqlClient.SqlInternalConnection.OnError(SqlExcep tion
> exception, Boolean breakConnection)
> at
> System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(Tds ParserStateObj=
e=ADct
> stateObj)
> at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
> SqlCommand cmdHandler, SqlDataReader dataStream,
> BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
> stateObj)

Never mind, i just gave my SQL user owner permissions on the msdb
database. Duh. Sorry to waste anyone's time.

Re: SQL Server 2005 MSDB Access

am 15.04.2008 19:33:30 von Norman Yuan

Also, do not name your own stored procedure like "sp_xxxxxxx", which is used
for system stored procedures.

wrote in message
news:ae94a163-9b99-4c51-af40-68ecc63c9b31@f36g2000hsa.google groups.com...
On Apr 15, 10:20 am, cap...@gmail.com wrote:
> Sorry, the above message is not correct (I pasted the wrong message).
> This is the error I am getting...
>
> System.Data.SqlClient.SqlException: EXECUTE permission denied on
> object 'sp_start_job', database 'msdb', schema 'dbo'.
> at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
> Boolean breakConnection)
> at System.Data.SqlClient.SqlInternalConnection.OnError(SqlExcep tion
> exception, Boolean breakConnection)
> at
> System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(Tds ParserStateObje­ct
> stateObj)
> at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
> SqlCommand cmdHandler, SqlDataReader dataStream,
> BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
> stateObj)

Never mind, i just gave my SQL user owner permissions on the msdb
database. Duh. Sorry to waste anyone's time.