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
Microsoft SQL Server

Avatar of undefined
Last Comment
imran_fast

8/22/2022 - Mon
imran_fast

Create a linked server with the sybase and then use open query to update the table in sybase.
imran_fast

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
imran_fast

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
imran_fast

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
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23