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 2005 Forums
 Transact-SQL (2005)
 not an option

Author  Topic 

doran_doran
Posting Yak Master

179 Posts

Posted - 2009-12-04 : 12:33:19
Okay, I came to learn one of the database will not allow triggers to add. (luckily few of them will allow).

Question is: I was using triggers on insert, update. How can I accomplish similar using stored procedure. and how is the scheduling is done (i mean how often the sp will kick in and how will it know the modification or insert)?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-04 : 12:38:51
Wherever you are performing your insert and update, just add code there to do whatever you wanted inside the trigger.

Stored procedures have no knowledge of insert or update actions.

Are you already using stored procedures for your data modifications or is it done from your application?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

doran_doran
Posting Yak Master

179 Posts

Posted - 2009-12-04 : 13:52:59
1. I cannot have triggers.
2. Idea is if a record been added or update in one database's table (database1, table1) then it will add or update another database (database2, table2).
3. My plan was to use trigger on database1, table1 but that option is not available.

Now. given the fact above, what are my option? How can I achieve similar goal like triggers but using stored proc>
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-04 : 14:00:11
I don't think you understood my post. Where are you performing the data modifications for database1? From your application or stored procedure? Wherever it is, that's where you need to add code to include the data modifications for database2.

Why don't you consider transactional replication instead?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

doran_doran
Posting Yak Master

179 Posts

Posted - 2009-12-04 : 15:29:14
1. Data modification happens at database1.
2. There is no application that is tie to database1. (I mean there is but we are not touching the frontend). SO I am to use stored proc at database1 and there is no sp_send_dbmail for the database server. I am to send email notification as well on insert and update.
3. Transactional replication sound good but complicated. Never heard or use that term.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-04 : 15:52:47
You'll definitely need to use transaction replication due to your answer in #2. Start reading up on it!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -