Friday, August 14, 2009

cross database ownership in sqlserver 2000

this works on sqlserver 2000 since sp3.

(ATER DATABASE db SET DB_CHAINING ON is not working)
-- when I listed the options,the option is displayed as "DB CHAINING", no underscore is included.
--it also works with 'on' and 'off'
sp_dboption 'xxxdb','DB CHAINING',true
sp_dboption 'xxxdb','DB_CHAINING',true

after enabling the cross database ownership, as long as the creator of the stored procedure in one database has corresponding ownership in another database, the user in the calling database does not have to has db access to the second database as long as it's granted the privilege to execute the stored procedure.

Note: by default, in sqlserver 2000 sp3, the stored procedure is executed as it's creator's privileges.