bibi92
asked on
how to execute a stored procedure like sysadmin or workaround for checking mirroring
Hello,
I try to create a stored prod for checking db mirroring without be sysadmin :
create procedure check_mirror WITH EXECUTE AS ... AS
set nocount on;
SELECT a.name +'|'+ CAST(isnull(b.mirroring_ro le,'') AS varchar(15)) +'|'+ CAST(isnull(b.mirroring_pa rtner_inst ance,'') AS varchar(15))from sys.databases a INNER JOIN sys.database_mirroring b ON a.database_id=b.database_i d where mirroring_role is null or mirroring_role=1 or mirroring_role=2
Thanks
bibi
I try to create a stored prod for checking db mirroring without be sysadmin :
create procedure check_mirror WITH EXECUTE AS ... AS
set nocount on;
SELECT a.name +'|'+ CAST(isnull(b.mirroring_ro
Thanks
bibi
WITH EXECUTE AS OWNER
ASKER
I have tried this but it doesn't work. Thanks bibi
you need to create procedure being sysadmin
if this does not work, what error do you get?
create procedure check_mirror WITH EXECUTE AS SA
AS
...
and grant the permissions of the procedure to the user that needs to call this procedure.if this does not work, what error do you get?
ASKER
Hello,
The error is Msg 15151, Level 16, State 1, Procedure test, Line 3
Cannot execute as the user 'SA', because it does not exist or you do not have permission.
But I try to create the procedure with sysadmin account.
Thanks
Regards
bibi
The error is Msg 15151, Level 16, State 1, Procedure test, Line 3
Cannot execute as the user 'SA', because it does not exist or you do not have permission.
But I try to create the procedure with sysadmin account.
Thanks
Regards
bibi
sorry:
AS DBO
sa is the login, dbo is the user.
AS DBO
sa is the login, dbo is the user.
ASKER
Thanks I have tried with dbo but it doesn't work. There is no error but I can't query the sys.database_mirroring.
permissions requirments for sys.database_mirroring
http://msdn.microsoft.com/en-us/library/ms178655.aspx
http://msdn.microsoft.com/en-us/library/ms178655.aspx
ASKER
Yes, thanks, I know that but I search a workaround.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks bibi