Sp to sync two tables using linked servers

Hello everybody
I'm working in a SP and I got two tables in different servers, one is the main and the other is a copy but whit less columns, all I want is to run the SP every 5 min over the main table in order to validate if new records has been created, if yes take those
new records and insert them into the copy table, that resides in the other server.
Searching a solution I've found this script wich works ok in the same server, but when I try to run it with the linked server it fails....please somebody help me with this.
This is the code that I'm using:
ALTER PROCEDURE  sp_newrecords
AS
BEGIN
DECLARE @val1 int
DECLARE @val2 nvarchar(50)
DECLARE @val3 nvarchar(50)
    SET NOCOUNT ON;
    -- Insert statements for procedure here
DECLARE mycur1 CURSOR for
 select empid,fname,lname from employee
 where empid = 507
 OPEN mycur1
 FETCH NEXT FROM mycur1 INTO @val1, @val2 , @val3
 WHILE @@Fetch_Status = 0
 BEGIN
 begin tran /* default read committed isolation level is fine */
 if not exists (select * from employee_backup with (updlock, rowlock, holdlock)
                     where employee_backup.empid = @val1
                        and employee_backup.fname = @val2 )
     --insert employee_backup values (@val1, @val2 , @val3) -->this works fine
     INSERT [ESDBCGW001T].[LiquidacionD2D_security].[dbo].[Employee_backup] values (@val1, @val2 , @val3) -->This NOT
 --else
 --  /* update */
 commit /* locks are released here */
 FETCH NEXT FROM mycur1 INTO @val1, @val2 , @val3
 END
 CLOSE mycur1
 DEALLOCATE mycur1
END
GO
This is the error that a get....
OLE DB provider "SQLNCLI" for linked server "ESDBCGW001T" returned message "The partner transaction manager has disabled its support for remote/network transactions.".
Msg 7391, Level 16, State 2, Procedure sp_newrecords, Line 37
The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "ESDBCGW001T" was unable to begin a distributed transaction.
All configurations are perfect, and when I run the insert without the variables runs fine,I mean, instead of @val1, @val2 and @val3 I use real values 1, 'A', 'B'.
PD. Sorry if my english is not so good.
Edgardo Mancía

Hi,
Seems to be a DTC issue.
These links may help you fix your problem
http://www.sqlservices.com/web/news.aspx?NewsID=113
https://social.msdn.microsoft.com/Forums/en-US/7172223f-acbe-4472-8cdf-feec80fd2e64/the-partner-transaction-manager-has-disabled-its-support-for-remotenetwork-transactions?forum=adodotnetdataproviders
Cheers
Bhanu

Similar Messages

  • Need help to join two tables using three joins, one of which is a (between) date range.

    I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
    the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
    ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
    [ABCTABLE]
    ABCORDER
    ABCPART
    ABCSERIAL
    ABCDATE
    [ZYXTABLE]
    XYZORDER
    XYZPART
    XYZSERIAL
    XYZDATE1
    XYZDATE2

    Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
    on this computer. There are no "Null" fields in either of the tables. 
    This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
    [MSORDR]
    MSORDER
    MSPART
    MSSERIAL
    MSOPNDATE
    11111111
    4444444
    55555
    2/4/2015
    22222222
    6666666
    11111
    1/6/2015
    33333333
    6666666
    11111
    3/5/2015
    This table has one order for every part number and every serial number.
    [GLORDR]
    GLORDER
    GLPART
    GLSERIAL
    GLSTARTDATE
    GLENDDATE
    ABC11111
    444444
    55555
    1/2/2015
    4/4/2015
    ABC22222
    666666
    11111
    1/5/2015
    4/10/2015
    AAA11111
    555555
    22222
    3/2/2015
    4/10/2015
    Post Query table
    GLORDER
    MSORDER
    GLSTARTDATE
    GLENDDATE
    MSOPNDATE
    ABC11111
    11111111
    1/2/2015
    4/4/2015
    2/4/2015
    ABC22222
    22222222
    1/5/2015
    4/10/2015
    1/6/2015
    ABC22222
    33333333
    1/5/2015
    4/10/2015
    3/5/2015
    This is the SQL minus the between date join.
    SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
    FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART);

  • How we relate two tables using foreign key(fk)?

    hi to all,
        what are the conditions has to follow to relate two tables.I.e.,
    the two tables have same primary keys(pk). if we relate these two tables in one table the pk and fk will be the same then how that table in active.

    Hi
    To relate two tables..we have foreign key relationship.
    In one table v have primary key and in the second table, the same key is foreign key for that table..
    To relate two tables, we can use JOINS
    If there is already a suitable foreign key between two tables used in the view, these tables can be linked with a join condition from this foreign key.
    Create a view on tables TAB1 and TAB2. TAB1 is the primary table of the view. TAB2 is the secondary table of the view. TAB1 is the check table for TAB2. The foreign key fields are assigned to the check table fields as follows:
    TAB1-FIELD_A assigned to TAB2-FIELD_1
    TAB1-FIELD_A assigned to TAB2-FIELD_1
    The join condition of the view generated from the foreign key is then:
    CREATE VIEW ... AS SELECT ... WHERE TAB2-FIELD_1 = TAB1-FIELD_A AND TAB2-FIELD_2 = TAB1-FIELD_B.
    Join conditions can also be copied from generic and constant foreign keys. If a constant is assigned to a field in the foreign key, it is also assigned to the field in the join condition. There is no join condition for a generic relationship in the foreign key.
    The foreign key between tables TAB1 (check table) and TAB2 (foreign key table) is defined as follows:
    TAB1-FIELD_A assigned to TAB2-FIELD_1
    TAB1-FIELD_B generic
    TAB1-FIELD_C assigned to constant ‘C’
    The join condition for the view generated from the foreign key is in this case:
    CREATE VIEW ... AS SELECT ... WHERE TAB2-FIELD_1 = TAB1-FIELD_A AND TAB2-FIELD_2 = ‘C’.
    Hope it helps
    Reward if useful.

  • Operates on two table using procedure

    i want to handle two table using procedure in oracle 10g. i have created a procedure like this
    CREATE OR REPLACE PROCEDURE sold_car1(
    sid soldcar.sold_id%TYPE,
    cid soldcar.id%TYPE,
    cuid soldcar.customer_id%TYPE,
    eid soldcar.emp_id%TYPE,
    d soldcar.dat%TYPE
    ) IS
    BEGIN
    INSERT INTO soldcar VALUES(sid,cid,cuid,eid,to_date(d,'yyyy/mm/dd'));
    DELETE FROM pcar where id=cid;*
    COMMIT;
    END sold_car1;
    SHOW ERRORS
    i have found some errors. how can i do this.

    hi
    the errors are something like this ''the procedure is created with some errors''.
    actually i want to pass 4 parameters in the procedure that will insert in one table and among the 4 parameters by using one parameter i want to delete one row of another table.
    INSERT INTO soldcar VALUES(sid,cid,cuid,eid,to_date(d,'yyyy/mm/dd')); //soldcar is first table
    DELETE * FROM pcar where id=cid; //pcar is second table

  • Compare two tables on different server without using Linked Servers

    I have an SSIS package that needs to compare a table to another table on another server.  Then only delete data from the first table if it exists in the second table.  
    I know this is possible with Linked Servers but we are doing away with them in my company.  Is there a way inside of SSIS to do this?
    Oh and I can't use a Data Flow since I don't know the table names or columns at run time (the whole package is dynamic) so I can't map the columns ahead of time.  
    So no MERGE JOIN unless it can be used outside of a Data Flow.  

    You 'll have to use the Data Flow Transformation, thing is, given the constraints, your only option seems to be in generating the package programmatically (using code).
    The type of a program would be a Windows Console. The program would expect a few parameters as the source and target tables along with any necessary connection parameters.
    Then use the merge join (being the easiest to code in) in an Execute SQL Task component.
    Examples of coding packages:
    Samples for creating SSIS packages programmatically
    PS: I can tell you, given your circumstances, at the very minimum the impact on the bottom line of your company is brittle apps accompanied with expensive maintenance which translates into reduced ROI from your tooling.
    Arthur My Blog
    The package is table driven and is a dynamic archival process.  The end user just fills in the framework table and the package archives data from within a certain time range.  The table can exist on any server, any database.  
    That part is done.  The part that still needs to be accomplished is to delete data out of the base table since it is archived.  I need a safe way of doing this and so thought to compare the archive table against the base table.  Because they
    can exist anywhere and can have any name I am not sure how to do this without Linked Servers.  That being said we will not have Linked Servers for this.  
    Is there another safe way to delete data out of the base table?

  • Join two table using two link field

    hi all
    i need to left join two table, and to link two table need to match two field
    ex: the link field is store_name and id
    i use below sql statement
    SELECT A1.store_name, A1.id, A1.card, A2.sale, A2.history
    FROM Georgraphy A1, Store_Information A2
    WHERE A1.store_name = A2.store_name(+)
    AND A1.id = A2.id(+)
    but it's wrong
    please tell me how to left join A1 and A2, thx!

    Whats your aim?
    Any error message?
    SQL> select * from geography;
            ID STORE_NAME
             1 a
             1 b
             2 a
             2 b
    SQL> select * from store_information;
            ID STORE_NAME
             1 a
             3 d
    SQL> SELECT *
      2  FROM Geography A1, Store_Information A2
      3  WHERE A1.store_name = A2.store_name(+)
      4  AND A1.id = A2.id(+);
            ID STORE_NAME         ID STORE_NAME
             1 a                   1 a
             2 a
             2 b
             1 b                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Trying to use Linked Servers in SQL 2005 to connect to RDB 7

    I'm looking for detailed info on how to set up a linked server in SQL 2005 to connect to my Oracle RDB 7 database (running on VMS). I'm able to connect via odbc using VS.Net and Sql Server 2005 Reporting Services. I'm not sure if I need to use the ODP.NET or not. I have created a generic linked server, but it requires me to use the OpenQuery function to access the data, which is not giving me the functionality I'm looking for.

    Hi doanpq,
    Please download and install OLE DB Provider for Visual FoxPro 9.0, which exposes OLE DB interfaces that you can use to access Visual FoxPro databases and tables from other programming languages and applications. Please see:
    http://www.microsoft.com/en-us/download/details.aspx?id=14839
    Then, please follow up the following article to create a linked server:
    Creating Linked Servers:
    http://technet.microsoft.com/en-us/library/ff772782(v=sql.105).aspx
    For more information, you can also take a look at the following article, especially Dave K's comment:
    http://blog.dbase.integralwebsolutions.co.za/2008/10/accessing-your-dbf-tables-via-linked.html
    Elvis Long
    TechNet Community Support

  • Comparing two columns in two tables using partial text strings and copying data between tables

    I have two tables:
    The Vendor table is supplied by a clothing manufacturer and lists product data by row with a column that contains a unique manufacturer ID, such as T5C4.  In this table is a short product description and a long product description that I need to find and copy into the second table, Inventory.
    The Inventory table is an export from our Magento store.  Each row contains a unique inventory number in a column that includes but does not match the unique manufacturer ID from the Vendor table.  For example, the unique inventory number could be T5C4-W12, or RED-T5C4W12 or some other variation.
    For each product in Inventory, I need to find the matching product in Vendor, and then copy the short description and long description from Vendor to Inventory.
    Any tips?  Thanks!
    Karl

    Karl,
    Here's a start, as you requested.
    The formula for Our Inventory Row is:
    =IFERROR(MATCH("*"&A&"*", Our Inventory :: A, 0), "n/a")
    The formula for Brief Description in the inventory table is:
    =IFERROR(INDEX(ABC Products :: $A$1:$C$9,MATCH(ROW(), ABC Products :: $D, 0), 2), "n/a")
    The formula for the Full description in the inventory table is:
    =IFERROR(INDEX(ABC Products :: $A$1:$C$9,MATCH(ROW(), ABC Products :: $D, 0), 3), "n/a")
    The Manufacturer's table knows the concise product numbers, so it has the ability to search the Inventory table for it's product id's using wildcards and it then displays the line number of the item in the inventory table. The Inventory table can then search the manufacturer's table for its row number and can reference the brief and full descriptions.
    This approach has a serious limitation. It will only find the first occurrence in the inventory. Now, if you want to accept this, you can sort all the found descriptions and pull them out of the inventory table, and then the next product in line will display it's description too.
    I wish I could do better with this, but it's all I can come up with at this point, knowing only what you have told me.
    Jerry

  • Join on two tables using "LIKE"

    Hi all,
    I need make join on two tables (QMEL and STXL) using keys for connection:
    - field for join of first table is (QMEL-QMNUM - Notif. number - Char 12)
    - field for join of second table is  (STXL-TDNAME - Char 70)
    If it is connection based on EQ, I think, it's no problem but I need to connect it on base of 'LIKE'.
    Example:
    QMEL-QMNUM = '100100698075'
    I would like get all rows from STXL which contain or even better start with notif. number.
    Examples I would like connect with QMEL-QMNUM:
    STXL-TDNAME = '100100698075'
    STXL-TDNAME = '1001006980750001'
    STXL-TDNAME = '10010069807500010001'
    STXL-TDNAME = '10010069807500010002'
    etc..
    Am I able to manage that with select which join these two tables this way?
    Thanks for any solution
    Vaclav Hosek.

    Hi,
    Write 2 separate selects for this.
    select * from QMEL
    where......
    if sy-subrc = 0.
    loop at i_qmel into wa.
    r_tdname-option = 'CP'.
    r_tdname-sign = 'I'
    concatenate wa-qnum '*' into r_tdname-low.
    append r_tdname.
    endloop.
    select *
    from STL
    where tdname in r_tdname.
    endif.

  • Joining two tables using PL/SQL

    here i am trying to join two tables can any one tell me what is wrong with this syntex
    CREATE OR REPLACE PROCEDURE test IS
    CURSOR c1 IS SELECT seq,fname,lname from t1;
    CURSOR c2 IS SELECT seq1,q,a from t2;
    userjob number;
    BEGIN
         OPEN c1;
    insert into t3 values(c1.seq,c1.fname,c1.lname);
         FETCH c1.seq INTO userjob;
    FOR c1rec IN c2 LOOP
    IF (c1rec.seq=c1.seq and c1rec.q1='why') THEN
    insert into t3 values(c1rec.q1,c1rec.a1);
    elsif (c1rec.seq=c1.seq and c1rec.q1='what') then
    insert into t3 values(c1rec.q2,c1rec.a2);
    elsif (c1rec.seq=c1.seq and c1rec.q1='when') then
    insert into t3 values(c1rec.q3,c1rec.a3);
    elsif (c1rec.seq=c1.seq and c1rec.q1='where') then
    insert into t3 values(c1rec.q4,c1rec.a4);
         END IF;
         END LOOP;
         END;
    /

    You should always fetch a cursor before using it's values. All columns in the select should be fetched into variables or a record-variable. You can't refer to the cursor-columns values with c1.seq etc.
    r1 c1%rowtype;
    l_found boolean;
    BEGIN
    OPEN c1;
    FETCH c1 INTO r1;
    insert into t3 values(r1.seq,r1.fname,r1.lname);
    l_found := c1%found;
    close c1;
    if l_found
    then
    It is also better to close the cursor and check if the select resulted in a row. With this code you will only retrieve one row even if the select will result in multiple rows.
    But I agree with all the others that this can probably be done more efficiently with one SQL statement.

  • Subject: How to do join between two tables using something like SE16

    SE16, SE11 provide form based interface query information from a single table. Is there a way to do join between two tables without creating an infoset erc? I am looking for something similar to sql join but in SAP BI 7.0
    Thanks.

    Hi
    Pls look into below links. Hope this helps you.
    1. http://help.sap.com/saphelp_46c/helpdata/EN/d2/cb45bf455611d189710000e8322d00/content.htm
    2. http://help.sap.com/saphelp_46c/helpdata/EN/d2/cb45a5455611d189710000e8322d00/content.htm
    Regards
    Sirigiri

  • How to  Join two tables using the Inner Join

    Hi All,
    I have two tables i.e table1 and table2 as i have created two otds and my present requirement is to join this two tables and get the results and using this i need to do some logic and update another table3.
    can some one help me out how to go for the above req.
    Thanks in Advance
    Srikanth

    The best efficient way to use inner join is create two input otds,use there otd's in create a collaboration usinf etl.
    after selecting two input otd's create a inner join statement and map it to out put otd.
    while using the etl the performance of the over all integration is increased 20 time of the normal integration.
    Hopes this will helps,,
    Thanks,
    Papa Rao.

  • How to generate report from two tables using DAO design pattern?

    Hi,
    Iam using struts with DAO pattern for my application. According to DAO design im creating model class for each table in my database with getter,setter methods. i have no problem when im generating report from one table. but if have i have to join two tables whatis the better way for doing that? is it good practise to create a new model contains properties from both the tables?
    Please help me
    Thanks in Advance
    Rajesh

    Dear Rajesh,
    As per the pattern you are creating equivalent java objects for every database table under consideration in which each db field will become a private attribute and public getter and setter methods.
    If you have to display data from one table the above approach is sufficient enough.
    But in case your database is normalised ..lets take an example of Bank having Branch and Accounts tables. We dont need to repeat the whole information of the branch for every account in that branch. so we prefer to have a branch id in that table....this approach lot of insertion/deletion/updatation anomlies that may exists with the database...
    now lets come back to our topic....we shall create two java objects 1) Branch 2) Account.....
    When ever u just need to display simple report u can do it staright forward,,,,,now if u want to display branch information along with the account information....the two objects just created are not sufficient
    So i suggest u the following approaches
    1) Create an attribute of type Branch in the Accounts Object......
    This shall serve the purpose of displaying the Btranch information
    2) Create a collection object of type ( Vector or ArrayList) which can have objects of Account in the Branch Object,,,
    Now its upto u how shall u fill up the objects with appropriate sql queries.
    The method that i mentioned is followed by Oracle Toplink and Hibernate ....which provide Object to relation mapping layers.
    Any queries ...revert back to me...
    Mahesh

  • How to insert into two tables using a Single ADF creation form?

    Hi,
    I need to make a ADF Creation Form that will insert the data at same time in two tables... Like i have two tables Track (Track_id,Track_Name)
    and Module ( Module_id, Track_id, Module_name, Module_Short_name) and i have to insert the data in both the tables using Same Creation Form.
    can anybody help me out and gave me the solution,how to do that?
    Thanks

    if you want to insert different data into two different tables then you can drag the two data objects into creation form..
    If you want to duplicate the data inserted in the one table to another then you can follow two approach
    1. Drag and drop one table, When Save button is invoked then insert data into another table using callable statement.
    or
    2. Create on-insert trigger in Table1 where you can insert data into table2.
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Unable to retrive data from two tables using multiple joins

    Hi,
    Table:   EMP mgr 
    eid              name
    eid mgrid
    1
    A 1
    null
    2
    B 2
    3
    3
    C 3
    3
    i need to get result as:
    eid ename mgrname
    thanks
    AVS

    Sai,
    It would be very helpful if you could mention your table structures a bit more clearly. Would allow for effective replies from fellow users as well. :) 
    However, assuming that your structure would be as follows presenting the query as below:
    DECLARE @Emp TABLE(Eid Int, ename Varchar(50))
    DECLARE @Emp_Mgr TABLE(Eid int, mgrid int null )
    INSERT INTO @Emp select 1,'Ram'
    INSERT INTO @Emp select 2,'Shyam'
    INSERT INTO @Emp_Mgr select 1,NULL
    INSERT INTO @Emp_Mgr select 2,1
    SELECT * FROM @Emp
    SELECT * FROM @Emp_Mgr
    Query to print results as EID, ENAME, MGRNAME
    SELECT em.eid,e1.ename as ENAME,e2.ename as MGRNAME
    FROM @Emp_Mgr em
    JOIN @Emp e1 ON em.eid=e1.eid
    JOIN @Emp e2 ON em.mgrid=e2.eid
    However, as you see this approach of maintaining two tables for preserving the employee-manager data is redundant and makes the queries unnecessarily complex. So, you could opt for the widely used single table format as mentioned by Praveen as well. Check
    if this helps you..
    Recommended Structure
    *Avoidance of redundant storage of data
    *Lesser Joins in queries
    DECLARE @Emp TABLE(Eid Int , Ename Varchar(50) , mgrid int null )
    INSERT INTO @Emp(Eid , ename , mgrid) values(1 , 'Ram' , null) , (2 , 'Shyam' , 1)
    SELECT * FROM @Emp
    Query to print results as EID, ENAME, MGRNAME
    SELECT e.Eid , e.Ename , m.Ename as MgrName
    FROM @Emp e
    JOIN @Emp m On a.mgrid = b.eid
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

Maybe you are looking for

  • Multi plot cursor in Mixed Graph

    If Digital waveform and normal waveform graph is plotted in a mixed graph, and if I choose watch all plots(multi plot) in cursor, LabVIEW closes immediately with an error popup dialog I have attached the print screen image of that error popup Attachm

  • Handbrake Screen Size

    I made an interesting discovery on handbrake by accident last night. I put in Indiana Jones and the Temple of Doom before I went to bed, adjusted all the settings but forgot to adjust the screen size. I've done this before and I usually would have ju

  • Issues seeing database tables in DW CS5

    Hello,  I'm writing PHP pages to manage, create new, edit and delete rows in some tables in a mySQL database I've created. I've connected successfuly and see all 5 tables in the database tab However, of the five tables in the database when I click on

  • What is guiXT?

    Hi: Could GuiXT be used for purpose of data extraction directly from SAP? What is the main purpose of this tool? Thanks, Asif Message was edited by: Asif Rahmetulla

  • Updating Extension Manager 6.0.5 for Photoshop CS6 Mac

    I just ran an update on Adone Application Manager and received the folloc error: Extension Manager 6.0.5 Update Installation failed. Error Code: U44M1P7 I changed the permissions of "Adobe Extension Manager CS6" to read and write. Noticed an Adobe fo