Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

The target is not in the current database

$
0
0

Can someone please help me with the following error?

 

I am trying to create a trigger that copies data from a table in one database to another. However I am getting the error 'Cannot create trigger on databasename.dbo.tablename as the target is not in the current database.

 

Below is the SQL I am using to create the trigger:

create

trigger addtotable1

on

databasename.dbo.tablename

for

insert

as

insertinto anotherdatabase.dbo.tablename

select databasename.dbo.tablename.userid, databasename.dbo.tablename.username, biadatabasename.dbo.tablename.issuperuser

from databasename.dbo.tablename, inserted

where databasename.dbo.tablename.userid = inserted.userid

and inserted.roleid = 3

 

Andrew Ling


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>