Re: A severe error occurred on the current command when running stored

From: Val Mazur (group51a_at_hotmail.com)
Date: 10/30/04


Date: Sat, 30 Oct 2004 15:22:48 -0400

Hi,

Sine it is working fine with admin, I would suspect it is related to
permissions issues. Here is what I have found in a BOL for SQL Server. I
think it might help you

"When sp_help_job is invoked by a user who is a member of the sysadmin fixed
server role, sp_help_job will be executed under the security context in
which the SQL Server service is running. When the user is not a member of
the sysadmin group, sp_help_job will impersonate the SQL Server Agent proxy
account, which is specified using xp_sqlagent_proxy_account. If the proxy
account is not available, sp_help_job will fail. This is true only for
Microsoft® Windows NT® 4.0 and Windows 2000. On Windows 9.x, there is no
impersonation and sp_help_job is always executed under the security context
of the Windows 9.x user who started SQL Server."

-- 
Val Mazur
Microsoft MVP
"Macromullet" <Macromullet@discussions.microsoft.com> wrote in message 
news:CD1B5B1C-30D3-412C-95D1-7CA8EDFFD6CF@microsoft.com...
>I am trying to execute the following stored procedure:
>
> sp_help_job on msdb on a SQL Server 2000 installation under the context of 
> a
> user that is just a standard sql server login. Not a sysadmin.
>
> If i run it under the context of a sysadmin i get results. However, if i 
> run
> it under a basic user i get:
>
> A severe error occurred on the current command.  The results, if any, 
> should
> be discarded.
>
> I thought it might be related to not specifying parameters but i did that
> too. Here is my code:
>
> public void ThisWillFail()
> {
> string connectionString = "Data Source=server;Initial
> Catalog=msdb;Integrated Security=false;User
> ID=basicuser;Password=basicuser;Application Name=TESTAPP;Persist Security
> Info=False;Connect Timeout=30;";
>
> SqlConnection sqlConnection = new SqlConnection(connectionString);
> SqlCommand sqlCommand = new SqlCommand("sp_help_job", sqlConnection);
>
> sqlCommand.CommandType = CommandType.StoredProcedure;
>
> sqlCommand.Parameters.Add("@job_id", SqlDbType.UniqueIdentifier);
> sqlCommand.Parameters.Add("@job_name", SqlDbType.NVarChar, 128);
> sqlCommand.Parameters.Add("@job_aspect", SqlDbType.VarChar, 9);
> sqlCommand.Parameters.Add("@job_type", SqlDbType.VarChar, 12);
> sqlCommand.Parameters.Add("@owner_login_name", SqlDbType.NVarChar, 128);
> sqlCommand.Parameters.Add("@subsystem", SqlDbType.NVarChar, 40);
> sqlCommand.Parameters.Add("@category_name", SqlDbType.NVarChar, 128);
> sqlCommand.Parameters.Add("@enabled", SqlDbType.TinyInt);
> sqlCommand.Parameters.Add("@execution_status", SqlDbType.Int);
> sqlCommand.Parameters.Add("@date_comparator", SqlDbType.Char, 1);
> sqlCommand.Parameters.Add("@date_created", SqlDbType.DateTime);
> sqlCommand.Parameters.Add("@date_last_modified", SqlDbType.DateTime);
> sqlCommand.Parameters.Add("@description", SqlDbType.NVarChar, 512);
>
> SqlDataReader dr = null;
>
> try
> {
> sqlConnection.Open();
> dr = sqlCommand.ExecuteReader();
>
> while (dr.Read())
> {
> System.Diagnostics.Debug.WriteLine(dr["name"]);
> }
> }
> catch (SqlException ex)
> {
> System.Diagnostics.Debug.WriteLine(ex.ToString());
> }
> finally
> {
> if (dr != null && !dr.IsClosed)
> {
> dr.Close();
> }
>
> if (sqlConnection.State == ConnectionState.Open)
> {
> sqlConnection.Close();
> }
> }
> }
>
> Any help is greatly appreciated.
>
> -Brooke 


Relevant Pages

  • Re: permissions required for executing CDOSys stored procedures
    ... he is by default member of the sysadmin server ... role on the SQL Server database unless steps are taken to prevent that. ... sysadmin and who has not been granted specific execute permissions on the ... it is possible to GRANT EXECUTE ON sp_OACreate TO ...
    (microsoft.public.sqlserver.security)
  • Re: Changing SQL Servers Service Account
    ... When xp_cmdshell is invoked by a user who is a member of the sysadmin fixed ... which the SQL Server service is running. ... xp_cmdshell will impersonate the SQL Server Agent proxy ... Microsoft® Windows NT® 4.0 and Windows 2000. ...
    (microsoft.public.sqlserver)
  • Re: Sharepoint index problems in SQL Server.
    ... The Administrator account is a sysadmin and have all the access to all the ... > database is master and language US_English? ... >> I've set back the account localsystem for both SQL Server and Microsoft ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Cant edit logins or server roles
    ... BUILTIN\Administrators is in the sysadmin role, ... if I am part of the machine's windows ... > others have changed what SQL Server server role this group belongs to. ...
    (microsoft.public.sqlserver.security)
  • Re: Move or Setup of SQL Database toa Remote Server Fails
    ... as well as have SysAdmin privileges on the DB. ... Registered type 501ST MASTER for 501ST SCCM1DB\master ... Could not connect SQL Server 'master' db. ... The SCCM Primary Site Computer Account and the User account I am using ...
    (microsoft.public.sms.setup)