Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Accessing another database table from my database

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-02-12 : 21:52:34
Muhammad writes "I am using the SQL Server 2005.
I have two different databases having the same table schema in both. Each database has its own user name & password, means different login for each database. The task is that I have to copy a record by firing a trigger placed on the table in database A.
After inserting the record in table in the database A, trigger tries to copy the record in the table in database B.

But exception occurs that "You don't have permission to access the table in the database B under this security context".
But if works fine when there's same login on both databases, with same user name and password having the same privileges. Do you have any idea how to do it when login is different or any alternative solution that is secured for rest of the tables in the database B.

Thanks

Rizwan"

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2007-02-12 : 22:48:43
You can try using a linked server instead. It seems silly to put a link in place for a connection on the same server though.

Why don't you just grant the user access to the specific objects you are querying (rather than complete access) via a database role. That would be much easier to implement (and be the correct way to do things as well).



-ec
Go to Top of Page
   

- Advertisement -