In the BOL is says that DBO and sy

However, the database owner gets this error:
Server: Msg 15247, Level 16, State 1, Procedure sp_updatestats, Line 14
User does not have permission to perform this action.
I've found that I can only run it as sy

were the code is raising the error:
DECLARE @.dbsid varbinary(85)
SELECT @.dbsid = sid
FROM master.dbo.sysdatabases
WHERE name = db_name()
/*Check the user sy

IF NOT is_srvrolemember('sy

BEGIN
RAISERROR(15247,-1,-1)
RETURN (1)
END
So is the BOL wrong or the SP?
Thanks,
BryanI think that's a bug. You can now only run sp_updatestats if you are logged
in as the account that owns the database. Being a member of dbo is not
enough, where I think it should be.
You can replace
AND suser_sid() <> @.dbsid
with
AND IS_MEMBER ('db_owner') = 0
to make the procedure work as expected.
Jacco Schalkwijk
SQL Server MVP
"BDB" <reply@.to.group.com> wrote in message
news:%23qPHC52aFHA.796@.TK2MSFTNGP09.phx.gbl...
> Hi,
> In the BOL is says that DBO and sy

> However, the database owner gets this error:
> Server: Msg 15247, Level 16, State 1, Procedure sp_updatestats, Line 14
> User does not have permission to perform this action.
> I've found that I can only run it as sy

> see were the code is raising the error:
> DECLARE @.dbsid varbinary(85)
> SELECT @.dbsid = sid
> FROM master.dbo.sysdatabases
> WHERE name = db_name()
> /*Check the user sy

> IF NOT is_srvrolemember('sy

> BEGIN
> RAISERROR(15247,-1,-1)
> RETURN (1)
> END
>
> So is the BOL wrong or the SP?
> Thanks,
> Bryan
>|||Correction:
On rereading the BOL article about sp_updatestats is seems to me that the
article and the code of the stored procedure are technically in agreement.
However using the database owner instead of the db_owner role is highly
unusual. I think it is the first time I have seen it used in SQL Server.
Regarding changing sp_updatestats, as I suggest below, and system stored
procedures in general:
Changing system stored procedures is not recommended or supported by
Microsoft, and if something goes wrong you will be on your own.
I'll raise this issue with Microsoft on your behalf though.
Jacco Schalkwijk
SQL Server MVP
"Jacco Schalkwijk" <jacco.please.reply@.to.newsgroups.mvps.org.invalid> wrote
in message news:ejILv%233aFHA.2860@.TK2MSFTNGP10.phx.gbl...
>I think that's a bug. You can now only run sp_updatestats if you are logged
>in as the account that owns the database. Being a member of dbo is not
>enough, where I think it should be.
> You can replace
> AND suser_sid() <> @.dbsid
> with
> AND IS_MEMBER ('db_owner') = 0
> to make the procedure work as expected.
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "BDB" <reply@.to.group.com> wrote in message
> news:%23qPHC52aFHA.796@.TK2MSFTNGP09.phx.gbl...
>|||Right, I'll probably just make a second system SP that works as expected and
wait for MS to fix there own bug.
Thanks a lot!
Bryan
"Jacco Schalkwijk" <jacco.please.reply@.to.newsgroups.mvps.org.invalid> wrote
in message news:uxYHKD4aFHA.1040@.TK2MSFTNGP10.phx.gbl...
> Correction:
> On rereading the BOL article about sp_updatestats is seems to me that the
> article and the code of the stored procedure are technically in agreement.
> However using the database owner instead of the db_owner role is highly
> unusual. I think it is the first time I have seen it used in SQL Server.
> Regarding changing sp_updatestats, as I suggest below, and system stored
> procedures in general:
> Changing system stored procedures is not recommended or supported by
> Microsoft, and if something goes wrong you will be on your own.
> I'll raise this issue with Microsoft on your behalf though.
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "Jacco Schalkwijk" <jacco.please.reply@.to.newsgroups.mvps.org.invalid>
> wrote in message news:ejILv%233aFHA.2860@.TK2MSFTNGP10.phx.gbl...
>
No comments:
Post a Comment