I thought I could do this by granting permission to a few MSDB
procedures:
grant execute on sp_help_jobhistory to UserRole -- view job history
grant execute on sp_help_job to UserRole -- view job
grant execute on sp_start_job to UserRole -- start job
but I get an error:
Server: Msg 14262, Level 16, State 1, Line 1
The specified @.job_name ('Name Of Job') does not exist.
I looked at the sysjobs_view in MSDB (below) it looks like only the
owner, SysAdmins and TargetServersRole (what is this?) can view the
jobs. If I alter this view to include my UserRole this allows them to
start the job, but I don't want to do this because it is a hack.
SELECT *
FROM msdb.dbo.sysjobs
WHERE (owner_sid = SUSER_SID())
OR (ISNULL(IS_SRVROLEMEMBER(N'sysadmin'), 0) = 1)
OR (ISNULL(IS_MEMBER(N'TargetServersRole'), 0) = 1)
What is a better solution?We got around this by using a queue to disconnect the security.
1) create a queue table that takes the name of a job and a status value.
2) create a stored procedure that can read the queue, find any pending jobs,
run sp_startjob for any pending jobs, mark started jobs as complete.
3) create SQL Agent job owned by SA that runs once every minute and runs
that stored procedure.
4) user inserts job name in queue and waits ~1 min.
--
Thank you,
Daniel Jameson
SQL Server DBA
Children's Oncology Group
www.childrensoncologygroup.org
"Laurence" <laurencen@.eurostop.co.uk> wrote in message
news:1161622953.615964.21000@.k70g2000cwa.googlegroups.com...
>I thought I could do this by granting permission to a few MSDB
> procedures:
> grant execute on sp_help_jobhistory to UserRole -- view job history
> grant execute on sp_help_job to UserRole -- view job
> grant execute on sp_start_job to UserRole -- start job
> but I get an error:
> Server: Msg 14262, Level 16, State 1, Line 1
> The specified @.job_name ('Name Of Job') does not exist.
> I looked at the sysjobs_view in MSDB (below) it looks like only the
> owner, SysAdmins and TargetServersRole (what is this?) can view the
> jobs. If I alter this view to include my UserRole this allows them to
> start the job, but I don't want to do this because it is a hack.
> SELECT *
> FROM msdb.dbo.sysjobs
> WHERE (owner_sid = SUSER_SID())
> OR (ISNULL(IS_SRVROLEMEMBER(N'sysadmin'), 0) = 1)
> OR (ISNULL(IS_MEMBER(N'TargetServersRole'), 0) = 1)
>
> What is a better solution?
>|||I see there is a way to do this by adding the user to the
TargetServersRole in MSDB, although it has a downside. See here:
http://www.mcse.ms/message638764.html
Daniel Jameson wrote:
> We got around this by using a queue to disconnect the security.
> 1) create a queue table that takes the name of a job and a status value.
> 2) create a stored procedure that can read the queue, find any pending jobs,
> run sp_startjob for any pending jobs, mark started jobs as complete.
> 3) create SQL Agent job owned by SA that runs once every minute and runs
> that stored procedure.
> 4) user inserts job name in queue and waits ~1 min.
> --
> Thank you,
> Daniel Jameson
> SQL Server DBA
> Children's Oncology Group
> www.childrensoncologygroup.org
> "Laurence" <laurencen@.eurostop.co.uk> wrote in message
> news:1161622953.615964.21000@.k70g2000cwa.googlegroups.com...
> >I thought I could do this by granting permission to a few MSDB
> > procedures:
> >
> > grant execute on sp_help_jobhistory to UserRole -- view job history
> > grant execute on sp_help_job to UserRole -- view job
> > grant execute on sp_start_job to UserRole -- start job
> >
> > but I get an error:
> >
> > Server: Msg 14262, Level 16, State 1, Line 1
> > The specified @.job_name ('Name Of Job') does not exist.
> >
> > I looked at the sysjobs_view in MSDB (below) it looks like only the
> > owner, SysAdmins and TargetServersRole (what is this?) can view the
> > jobs. If I alter this view to include my UserRole this allows them to
> > start the job, but I don't want to do this because it is a hack.
> >
> > SELECT *
> > FROM msdb.dbo.sysjobs
> > WHERE (owner_sid = SUSER_SID())
> > OR (ISNULL(IS_SRVROLEMEMBER(N'sysadmin'), 0) = 1)
> > OR (ISNULL(IS_MEMBER(N'TargetServersRole'), 0) = 1)
> >
> >
> > What is a better solution?
> >
Showing posts with label history. Show all posts
Showing posts with label history. Show all posts
Wednesday, March 21, 2012
Monday, March 19, 2012
How to edit backup history
I am using SQL Enterprise manager to manually backup test databases on
my PC.
As time goes on the list of backups is getting long and cumbersome,
and I no longer need many of them
Is there a way I can remove entries from the backup history for a
specific database to tidy up the even increasing list.
Thanks for any help
RichardF
Hi,
Use the system procedure:-
USE msdb
go
EXEC sp_delete_backuphistory '07/20/2004'
Deletes all the history older than july 20 2004. But there is no option to
clear the histories for a sinle database
Thanks
Hari
MCDBA
"RichardF" <no.one@.no.where.com> wrote in message
news:41114edb.172348764@.msnews.microsoft.com...
> I am using SQL Enterprise manager to manually backup test databases on
> my PC.
> As time goes on the list of backups is getting long and cumbersome,
> and I no longer need many of them
> Is there a way I can remove entries from the backup history for a
> specific database to tidy up the even increasing list.
> Thanks for any help
> RichardF
|||There is a separate proc to delete the history of a single database:
EXEC msdb.dbo.sp_delete_database_backuphistory dbname
You cannot specify a date however - it will delete all the backuphistory data
JustinR
"RichardF" wrote:
> I am using SQL Enterprise manager to manually backup test databases on
> my PC.
> As time goes on the list of backups is getting long and cumbersome,
> and I no longer need many of them
> Is there a way I can remove entries from the backup history for a
> specific database to tidy up the even increasing list.
> Thanks for any help
> RichardF
>
my PC.
As time goes on the list of backups is getting long and cumbersome,
and I no longer need many of them
Is there a way I can remove entries from the backup history for a
specific database to tidy up the even increasing list.
Thanks for any help
RichardF
Hi,
Use the system procedure:-
USE msdb
go
EXEC sp_delete_backuphistory '07/20/2004'
Deletes all the history older than july 20 2004. But there is no option to
clear the histories for a sinle database
Thanks
Hari
MCDBA
"RichardF" <no.one@.no.where.com> wrote in message
news:41114edb.172348764@.msnews.microsoft.com...
> I am using SQL Enterprise manager to manually backup test databases on
> my PC.
> As time goes on the list of backups is getting long and cumbersome,
> and I no longer need many of them
> Is there a way I can remove entries from the backup history for a
> specific database to tidy up the even increasing list.
> Thanks for any help
> RichardF
|||There is a separate proc to delete the history of a single database:
EXEC msdb.dbo.sp_delete_database_backuphistory dbname
You cannot specify a date however - it will delete all the backuphistory data
JustinR
"RichardF" wrote:
> I am using SQL Enterprise manager to manually backup test databases on
> my PC.
> As time goes on the list of backups is getting long and cumbersome,
> and I no longer need many of them
> Is there a way I can remove entries from the backup history for a
> specific database to tidy up the even increasing list.
> Thanks for any help
> RichardF
>
Subscribe to:
Posts (Atom)