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.
| Author |
Topic |
|
tobtob
Starting Member
7 Posts |
Posted - 2010-12-02 : 09:36:58
|
| I have a table (Users) that I need to update in two different databases (Same MSSQL Server). Basically, when a new user registers I want to add the record to the users table in both tables/db's. When a user "redeems an activation code" I want to UPDATE that field in both tables/DB's. Is there anything special to do other than simply issue the statements twice. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-12-02 : 09:44:14
|
| Depends what you want to do on failure.You could issue both statements in a transaction.You could have a trigger on one table that updates the other.In both of these cases the transaction will be held until both tables are updated and a rollback will cause both to fail.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-12-02 : 10:21:13
|
| OR set a up a Transaction replication.PBUH |
 |
|
|
tobtob
Starting Member
7 Posts |
Posted - 2010-12-02 : 11:17:58
|
| Thanks for the help but I am truly a beginner with SQL. I looked into transactions and triggers slightly but it would be very helpful if you could supply some code examples. The transactional replication seemed complicated to me. It might be overkill for our situation. (not much traffic)Thanks |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-12-02 : 11:34:56
|
| just enacpsult the statements in a transactionAlso include error handlingMuch more control if this is in a strored procedurecreate proc s_updateWhatever@parms...asbegin trybegin transtatement 1statement 2commit tranend trybegin catchrollback tran-- error handlingend catch==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|