Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run SQL job based on record insert in table

Status
Not open for further replies.

bt7403

Programmer
Nov 5, 2006
14
0
0
US
I need to run sql job based on a record being inserted to a table. The record gets inserted baed on merge replication from other clients, after insert I want a job to invoke. How to make this happen?

running SQL 2K5-familiar w/ running sql jobs, never used triggers-not sure how to create 'insert trigger' or if I can invoke sql job from it.

Pls. advise.
 
You will need to use a trigger to run the command.

Look up CREATE TRIGGER in Books OnLine for the full syntax for creating triggers.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
I was able to get triggers to work after review of SQL Books Online..thx

Next issue:
I have merge replication setup on two servers (server A is SUB, server B is PUB).
When I insert new record in server B table1, I need trigger to replicate new record to server A table1.
Not sure how to trigger EXEC SQL job to initiate snapshot, then merge agent on server A from server B. I do not want to use time schedules. I need a trigger.
 
The entire point of merge replication is that data should be able to be shipped in both directions. If you have to write something to do this manually then the repliaction isn't setup correctly.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
I have replication working fine on both ends-problem is replication only allows use of time schedule, which I don't like;I have to use triggers to invoke replication.
I have been trying to create a linked server to invoke my SQL job on the SUB(Server A) from PUB on Server B.
I was successful at querying in 4-part notation a table on Server B (PUB) from Server A. However, I can not perform inverse. I get "SQL Network Interfaces-Access denied" error.
I have the linked server (named as ServerA), but can't get any query to work. Settings are same on both linked servers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top