Link to home
Start Free TrialLog in
Avatar of spaceplanner
spaceplanner

asked on

SQL server trigger to update sybase database

Is it possible to write a trigger on a SQL Server table that will update data in a sybase database?

If so, how does one do it? what is the syntax

thanks
paul
Avatar of imran_fast
imran_fast

Create a linked server with the sybase and then use open query to update the table in sybase.
This is how you can do it
1.Create an odbc to the sysbase database
2.sp_addlinkedserver
Creates a linked server, which allows access to distributed, heterogeneous queries against OLE DB data sources. After creating a linked server with sp_addlinkedserver, this server can then execute distributed queries. If the linked server is defined as Microsoft® SQL Server™, remote stored procedures can be executed.
3.Run Open Query to update the table
4.Create a trigger on orignal table  to include this openquery statement.
ASKER CERTIFIED SOLUTION
Avatar of imran_fast
imran_fast

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
this is how you can do update in open query

update openquery(LinkedServerName,  'select  LAST_UPDATE_DATE from schemax.tablex  where transaction_id = 1') set LAST_UPDATE_DATE  = 'newvalue'
go