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 2000 Forums
 SQL Server Administration (2000)
 Trigger

Author  Topic 

shanly
Starting Member

17 Posts

Posted - 2005-08-17 : 12:44:59
x

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2005-08-17 : 17:50:01
If you have actually defined the linked server, try referencing the table using 4-part naming instead of OPEN QUERY. Something like:

SELECT * FROM linkedservername.databasename.ownername.tablename.

But apart from that, what are you trying to get this trigger to do? Your definition just has two select statements. Are you trying to initially populate the contents of one table into another? In that case you don't need a trigger, just and INSERT...SELECT statement. Or are you trying to keep them synchronized? In that case you need an INSERT...SELECT inside your trigger.

---------------------------
EmeraldCityDomains.com
Go to Top of Page

shanly
Starting Member

17 Posts

Posted - 2005-08-18 : 00:46:31
yes it is

insert into openquery(likedservername,'select * from username.tablename') select * from inserted.

i tried like select * from linkedservername.databasename.username.table in a trigger, it also not working.

only problem is trigger is not working.

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-08-18 : 03:22:32
"i tried like select * from linkedservername.databasename.username.table in a trigger "

Do you mean like:

INSERT INTO linkedservername.databasename.username.table
select * from inserted

??

Kristen
Go to Top of Page

shanly
Starting Member

17 Posts

Posted - 2005-08-18 : 05:00:38
INSERT INTO linkedservername.databasename.username.table
select * from inserted

is not working but i can insert data to remote server using

insert into openquery(linkedservername,'select * from linkedservername.databasename.owner.tablename') select * from owner.table

but not working in a trigger
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-08-18 : 05:32:57
Can you do an INSERT in the trigger if it is not using the INSERTED pseudo-table?

Such as:

insert into openquery(linkedservername,'select * from linkedservername.databasename.owner.tablename')
( Col1, Col2, Col3) VALUES ('aaa', 'bbb', 'ccc')

If so perhaps you could cursor round the rows in INSERTED and use @Variables to construct your insert statement?

Kristen
Go to Top of Page
   

- Advertisement -