SQL Server 2005 MSDB Access

C

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(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)

Any ideas?
 
C

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(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)
 
C

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(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObje­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.
 
N

Norman Yuan

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

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(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObje­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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top