What's the exact trigger for when updating/inserting/deleting data from one DB to another DB which contains same info?

Hi guys,
I have created a copy of the AdventureWorks2012 DB called AdventureWorks2012_new on the same instance.
I have created the following trigger below but my friend who is a DBA told me that this is not correct and I should be using the inserted table when creating this trigger. I would like AdventureWorks2012_new DB to be updating/inserting/deleting data from
the same tables that have been updated/inserted/deleted in the AdventureWorks2012 DB. How exactly should I do this for all the tables in the whole database ? What I have written below is just for one of the tables, is there a quicker way to do it for all tables
in this DB so that it performs the actions mentioned above, automatically ? Help would be greatly appreciated so I can understand how this works, thanks
CREATE TRIGGER [HumanResources].[tr_HumanResources_AfterUpdate]
ON [AdventureWorks2012].[HumanResources].[Department]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
UPDATE AdventureWorks2012_new.HumanResources.Department
SET Name = t2.Name,
GroupName = t2.GroupName,
ModifiedDate = t2.ModifiedDate
FROM AdventureWorks2012.HumanResources.Department AS t2
INNER JOIN AdventureWorks2012_new.HumanResources.Department AS t1
ON t2.DepartmentID = t1.DepartmentID
END

For insert it's easy:
CREATE TRIGGER [HumanResources].[tr_HumanResources_AfterInsert]
ON [AdventureWorks2012].[HumanResources].[Department]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
Insert INTO AdventureWorks2012_new.HumanResources.Department
(DepartmentID, Name, GroupName, ModifiedDate)
SELECT DepartmentID, Name, GroupName, ModifiedDate
FROM Inserted;
END
I didn't verify column names, so you may need to make sure to use correct column names for that table.
Setting replication is a bit advanced topic although BOL is clear and you may start here
http://technet.microsoft.com/en-us/library/ms151198.aspx
If it will be complicated for you, you can ask extra questions in the MSDN Replication forum.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles

Similar Messages

  • What's the best way to transfer (not forward) a call from one iPhone to another?

    What's the best way to transfer (not forward) a call from one iPhone to another? Is there an app available that does this? I'm asking about receiving a call, then transferring that caller to another iPhone on a separate number and then disconnecting while those two users are joined up in a conversation.

    Ask your carrier. This would be a feature provided by them.

  • What is the utility called to be able to use MSOffice from one mac to another?

    what is the utility called to be able to use MSOffice from one mac to another?
    thanks

    Remote Desktop Connection?
    Screen Sharing?

  • What is the easiest way to transfer a large imovie project from one computer to another in a different location.

    What is the easiest way to transfer an faairly large HD imovie project from one computer to another in a different location. Can you export to drop box? Will the other computer need the exact imovie version?

    OK it depends.
    If you have a finished movie, you can SHARE/EXPORT MOVIE and create your final movie. Then, depending on the size of the finished movie, you can transfer via dropbox or similar service. Ninety minutes is a very long movie for iMovie, but it may work for you. I would suggest 720P to keep the size down.
    If you need to transfer the entire iMovie Project so it can be edited in iMovie at the other end, then you need to transfer the project and event assets to an external hard drive and get the hard drive to the other location.
    Directions are here. Follow the directions for 1) Moving or copying Project to external drive. Then 2) Consolidate Media.
    https://discussions.apple.com/docs/DOC-4141

  • Update/insert/delete data from xcelsius to Database via web service

    Hi,
    I need to create dashboard that go function can <b>update/insert/delete</b> data send to <u>Database</u> thru <u>web services</u>, as i know got 2 xcelsius add-on software which support those of function <b>InfoBurst</b> and <b>flynet </b>
    <b>InfoBurst</b>
    http://www.infosol.com/azbocug/minutes/4-Writeback%20to%20a%20Database%20with%20Xcelsius.pdf
    <b>flynet </b>
    http://www.flynetviewer.com/public/community/Blogs/FlynetXcelsiusServerUser/default.aspx
    Except this 2 purchase add-on xcelsius, any other solution ?  
    Maybe need to write some in MSSQL or C# programming which enable insert, update, delete ...etc  ?
    *note: i not use Xcelsius Engage Server , i use Xcelsius Engage only
    thanks,
    regards
    s1
    Edited by: Leong Pui Kee on Mar 1, 2011 6:06 AM

    Hi,
    As of now in Xcelsius/Dashboard Design there is no feature or functionality to insert/update/delete data from database.
    Solution:
    Create a Web service in let’s say C# or Java, which will perform insert/update/delete operation.
    In Xcelsius add Web Service connection and user above web service.
    Xcelsius Web Service connection provides option to pass input values to a Web Service (Input Pane) and get the result (Output values pane).
    We can pass values to be written to the database as a input to Web Service via Web Service connection from Xcelsius and write data to the database.
    Note:
    Performing delete operation from Xcelsius Dashboard could be risky and may delete important data from database. I would not prefer giving delete option/functionality in Xcelsius dashboard.
    Hope this helps!
    Thank you.
    Regards,
    Vinay Mhaske

  • Error when trying to load data from one cube to another

    Hi Friends
    I am getting an error when using extractor checker for datamart data source. The cube in question is compressed. this is what i get when i view the logs.
    SQL Error: 575-
    SQL0575N  View or materialized query table "SAPBWP./BIC/VZTCOOMC02F" cannot be used because.
    Please help
    Thanking you in anticipation
    Samuel

    Rememberme -
         No, the SAP_FACTVIEWS_RECREATE program cannot and will not uncompress the data. A fact view exists for every infocube which combines the E and F fact tables. You can see this view using SE11 -> View -> /bic/vxxxxf (where xxxxx is your infocube tech name). When you run this program this view is dropped and recreated thus eliminating any incosistencies that lead to the error posted in this thread.
    Hope this helps!

  • What is the exact use of statistical updates in V1,V2 and V3

    Hi,
    Can anyone answer me some questions.
    1. what is the exact use of statistial update in V1,v2 and V3. If data is same in both document update and statistical update the why u need a second table with redundant data.
    2. When BW extracts data is it recommended to extract from statistical tables or document updated tables.(i read that statistical updation is tailored for reporting)
    3. Is V3 applicable only when BW extracts data from R/3.
    4.In case of V3 the initialization of updates are done from BW side or R/3 side. i mean is there any relationship between scheduling of dataloading using an infopackage in BW and the V3 process taking place in R/3

    1. First one has to understand that R3 is OLTP system purely used for transactin processing while BW is used for OLAP ie reporting purpose only. At a table level if we do not have  a redundant second table the R3 system will be over loaded when the OLTP & the OLAP systems access the same table for their respective purposes. So we have to take data from the document table with a time lag and put into the statistical tables so that BW will get the data as and when required.
    2. This question is related to 1 and the above answers both.
    3. V3 is a generic process and is used for data extraction from the R3 transaction tables and can be used for any system as such.
    4. Both the processes are independent of each other and there is no relationship.
    Hope this helps
    Cheers
    Viva
    Assign points if this helps.

  • What is the yellow portion "other" when updating your phone on itunes? What makes up that category?

    What is the yellow portion "other" when updating your phone on itunes? What makes up that category?

    anything that's not music, photos, apps, etc. anything that is not whatever is shown next to the other on the bottom of your screen. for example, if you look on your phone at settings, general, usage and click on any of the apps it will show you how much the actual app takes up and also how much documents and data it has; that documents and data portion will be counted as other. most phones that are operating normally have around 1gb of other so if you have a lot more than that you probably have a corrupt file or something. in that case search "removing other from iphone" will help you, but usually restoring is what will fix it.

  • What is the exact protocol for ejecting Time Machine disk from USB?

    I have an external drive that I connect and use for Time Machine. When I'm done, I eject the drive and Finder disappears. I pull the USB connector and the OS complains that I did not eject the drive properly.
    I've seem the other threads, and I'm afraid I'm going to get a lot of discussion and no answer. So here's a simple question:
    What is the exact protocol for closing Time Machine and disconnecting the USB cable to the drive without getting a complaint from the OS?
    Thanks
    Mike

    Drag the icon to the trash or highlight it and use the eject button or highlight it and use Command+e.

  • Trying to update apps on iPhone keeps saying funds not available which there are. What's the minimum balance for free updates?

    Trying to update apps on iPhone keeps saying funds not available which there are. What's the minimum balance for free updates?

    Updates are free. Upgrades aren't.

  • What is the exact syntax for calling remote function module.

    Hi to all
    1.....what is the exact syntax for calling remote function module.?
    Thanks and regards,
    k.swaminath reddy

    hi
    good
    Lets do simple example where you will first create a RFC in one server (say A) and create normal program in othere server (say B). Finally you will call the RFC in A from B.
    Do the following steps for creating RFC in server A.
    1. log on to server A
    2. go to se37
    3. Edit -> function groups-> create function group and give the function group name (say ZGRP).
    4. create a FM ( say Z_TEST_RFC) in se37 providing the function group which is created just now.
    5. go to attribute tab -> choose remote-enabled module from processing type.
    so that your FM will become RFC.
    6. provide the import parameter in import tab.
    we will provide only two import parameters.
    - parameter name : P_NUM1, typing: TYPE, associated type : I & check the pass value (all the parameters of RFC must pass by value).
    - parameter name : P_NUM2, typing: TYPE, associated type : I & check the pass value
    7. provide the export parameter in export tab.
    parameter name : P_SUM, typing: TYPE, associated type : I & check the pass value
    8. write the given simple code in source code tab.
    FUNCTION Z_TEST_RFC.
    P_TOT = P_NUM1 + P_NUM2.
    ENDFUNCTION.
    Do the following steps for creating ABAP program which will call the RFC in server B.
    1. se38 - > creat a program.
    2. write the given simple code.
    data tot type i.
    call function 'Z_TEST_RFC' destination 'XXXXXX'
    exporting
    p_num1 = 10
    p_num2 = 15
    importing
    p_tot = tot.
    write tot.
    please note that XXXXXX is RFC connection which is avialable in sm59 transaction in server A.
    -go to sm59 - > abap connection (list of RFC connection configurations are avialable). choose server B connection and replace it of XXXXXX in the code.
    finally you can execute the normal abap program that will call the RFC and display the result.
    reward point if helpful.
    thanks
    mrutyun^

  • What is the exact meaning for Screen Texts, GUI Status & GUI Titles

    What is the exact meaning for Screen Texts, GUI Status & GUI Titles and where we can find in SAP.
    What is called as these : Screen Texts, GUI Status & GUI Titles
    Kindly let me know.
    Akshtiha.

    Hi Akshitha,
    <b>Screen text</b>:They are labels that you can display beside your selection-screen parameters/select-options.. from the ABAP editor, use the menu option Go to> Text Elements>Selection Texts.
    <b>GUI STATUS</b>:go through this link
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba99935c111d1829f0000e829fbfe/content.htm
    <b>gui title</b>:The GUI status and GUI title are interface elements of screens. You create both of them using the Menu Painter in the ABAP Workbench. On screens, GUI statuses of type dialog status are used.
    Thanks
    Vikranth Khimavath

  • What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?

    Hi All,
    I am new to TestStand. Still in the process of learning it.
    What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?
    Thanks in advance,
    LaVIEWan
    Solved!
    Go to Solution.

    Hi,
    Using the Parameters is the correct method to pass data into and out of a sub sequence. You assign your data to be passed into or out of a Sequence when you are in the Edit Sequence Call dialog and in the Sequence Parameter list.
    Regards
    Ray Farmer

  • What is the table name for getting Last Receipt  & issue date of material?

    Hi Friends,
    What is the table name for getting Last Receipt  & issue date of material?
    *Case 1:*
    Here, I am running report in May 2008. But, if there is no goods receipt for the respective material since last 13th March 2007.
    Then in this case Last goods receipt date should be 13th March 2007.
    Please guide me.
    Regards
    Siva

    I checked MSEG table. But, I didn't find any field for date.
    Can you tell me field name.
    Regards
    Siva

  • My Mum( a pensioner) is wanting to purchase both an iPhone and iPad.  What is the best way for her to manage her data /calls/txt etc. obviously the cost needs to be as low as possible.  Currently does not have WiFi but uses dongle

    My Mum( a pensioner) is wanting to purchase both an iPhone and iPad.  What is the best way for her to manage her data /calls/txt etc. obviously the cost needs to be as low as possible.  Currently does not have WiFi but uses dongle

    My Mum( a pensioner) is wanting to purchase both an iPhone and iPad.  What is the best way for her to manage her data /calls/txt etc. obviously the cost needs to be as low as possible.  Currently does not have WiFi but uses dongle

Maybe you are looking for

  • Item number in sales order versus delivery not equal

    Hello Guru's, Please help me solve this problem, i created a sales order with 6 items in it and save it. Before I create the delivery I deleted the sales order item number 1,2 and 3 so the item that was redy for delivery are sales order items nubmer

  • Can't copy files to server folder

    I'm running Windows 7 Enterprise and need to copy the contents of a CD to one of our W2003 servers.  I have a shared folder on the server so I start copying files from the CD, to this folder.  Part way through the copy it says "You need permission to

  • Call webservice from abap

    Hello, I use the following code to call web service from abap, but in the method "http_client->receive"  i see "http_communication_failure = 1" . this is the code: DATA: SMS_TEXT       TYPE STRING,        SMS_TEXT_UTF   TYPE STRING,        SEND_STRIN

  • @Prompt causing funny issues

    Guys, I am migrating an universe  which is pointing to a SQL 2005 DB from 6.5 to xi 3.1 FP 1.5 and i am facing the below issue. In the universe i have a condition using the prompt function and it is as below: ((tablenamel.name in @Prompt('Select Name

  • Want to retrieve null value from xml?

    i m writing this code to get the tag name and values from xml file. Now the problem is that if my xml file contain any tag whose value is not defined like <root> <firsttag>first</firsttag> <Second></Second><Third>third</Third> </root> Now look if sec