We are using SQL2000. User insert table in one database DB1 and trigger insert the record into another database DB2. In this scenario, is it possible have a trigger in DB1 to execute a stored procedure in DB2 with a different user?
I think you may use openrowset in the trigger to update the other database. it is not the best practice but it is the only solution I know
OPENROWSET('SQLOLEDB','ServerName';'user';'Password',
'SELECT * FROM pubs.dbo.authors ORDER BY au_lname, au_fname')|||
hello,
if you will be doing this most of the times
you might as well use the sp_addlinkserver options "useself" set to false to create a
linked server
Syntax
sp_addlinkedsrvlogin [ @.rmtsrvname = ] 'rmtsrvname'
[ , [ @.useself = ] 'useself' ]
[ , [ @.locallogin = ] 'locallogin' ]
[ , [ @.rmtuser = ] 'rmtuser' ]
[ , [ @.rmtpassword = ] 'rmtpassword' ]
by setting useself to false you can enter the desired username and password
regards
|||
USE DB1
Go
EXEC sp_
Trigger ON INSERT
USE DB2
Go
EXEC sp_
Adamus
|||i wish the new sp for 200 would allow "execute as" feature in 2k5|||If this is in the trigger, is there any way I can run stored procedure with OpenRowSet and make trigger code invisible to the user who is inserting record since the password is there.
Thanks,
No comments:
Post a Comment