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?

Similar Messages

  • How do you join two tables from different Oracle schemas using a subquery

    I am trying to join two tables from different Oracle schemas using a subquery. I can extract data from each of the tables without a problem. However, when I combine the select statements using a subquery I get the Oracle error *'ORA-00936: missing expression'*. Since each SELECT statement executes on its own without error I don't understand what is missing. The result set I am trying to get is to match up the LINE_ID from PDTABLE_12_1 in schema DD_12809 with the MAT_DESCRIPTION from table PDTABLE_201 in schema RA_12809.
    The query is as follows:
    sql = "SELECT [DD_12809].[PDTABLE_12_1].LINE_ID FROM [DD_12809].[PDTABLE_12_1] JOIN " _
    + "(SELECT [RA_12809].[PDTABLE_201].MAT_DESCRIPTION " _
    + "FROM [RA_12809].[PDTABLE_201]) AS FAB " _
    + "ON [DD_12809].[PDTABLE_12_1].PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS"
    The format of the query is copied from a SQL programming manual.
    I also tried executing the query using a straight JOIN on the two tables but got the same results. Any insight would be helpful. Thanks!
    Edited by: user11338343 on Oct 19, 2009 6:55 AM

    I believe you are receiving the error because you are trying to JOIN on a column that doesn't exist. For example you are trying to join on FAB.PIPING_MATER_CLASS but that column does not exist in the subquery.
    If you want to do a straight join without a subquery you could do the following
    SELECT  DD_12809.PDTABLE_12_1.LINE_ID
    ,       FAB.MAT_DESCRIPTION
    FROM    DD_12809.PDTABLE_12_1
    JOIN    RA_12809.PDTABLE_201    AS FAB ON DD_12809.PDTABLE_12_1.PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS  HTH!

  • Compare two tables having different number of rows based on 2 columns

    Hi,
    I am having two tables table a having field1, field2 and table b having fields field1 and field2.
    I want those records from table a in which field1 of table a is not matching to field1 of table b and field2 of table b not matching to field2 of table b, but i also want the bifurcation of records as whether field 1 is not matching, field 2 is not matching or both fields 1 & 2 are not matching.
    e.g.
    table a table b
    field1 field2 field1 field2
    1 6 12 5
    2 5 1 9
    13 51 13 51
    45 31 99 121
    33 45
    In this case my output should be
    table a
    field1 field2 Mtchng_Field
    1 6 Field 2 not mtchng
    2 5 Field 1 not mtchng
    45 31 Feild1 and Field2 both not matching
    How would i get my result in the required format.

    sql>select * from t1;
    N1 N2 
    1   6 
    2   5 
    13  51 
    45  31 
    33  45 
    sql>select * from t2;
    N1 N2 
    12  5 
    1   9 
    13  51 
    99  121
    sql>
    select n1,n2,decode(nvl(p1,0)+nvl(p2,0),0,'No match',1,'F2 not match',2,'F1 not match','Match') status
    from(
      select n1,n2,(select 1
                   from t2 where n1=t1.n1) p1,(select 2
                                           from t2 where n2=t1.n2) p2
    from t1);
    N1 N2 STATUS 
    1   6   F2 not match 
    2   5   F1 not match 
    13  51  Match 
    45  31  No match 
    33  45  No match
    Message was edited by:
            jeneesh
    Message was edited by:
            jeneesh
    Some problems...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • BUG? BRIDGE statement to compare two tables

    Hello,
    I tried to compare two tables in different dbs and remembered a post about Cross Connectin Queries
    http://barrymcgillin.blogspot.com/2010/11/cross-connection-queries.html
    BRIDGE temparb AS "EB05 01"
    (SELECT * FROM arb)
    (SELECT * FROM temparb
    MINUS
    SELECT * FROM arb
    UNION ALL
    (SELECT * FROM arb
    MINUS
    SELECT * FROM temparb
    );I would expect to get the differences between the table arb in my current schema and the table arb alias temparb in the other db. Yet it seems, that in this case only the table in my current schema is read.
    I materialize the BRIDGE table with
    BRIDGE temparb AS "EB05 01"
    (SELECT * FROM arb)and select the value I know to be only in the remote schema
    SELECT id FROM temparb WHERE id = 2562;
    SELECT id FROM arb WHERE id = 2562;Both times I get no result. I even tried to use aliases on the table, same result. Tested in 3.0 and 3.1 EA3.
    Has anyone tried this before?
    Regards
    Marcus

    Hi Marcus,
    Have you tried it without the double quotes around the connection name?
    I have a connection called
    system_local
    which I run the following command in
    drop table testbridge_remote;
    drop table testdbrige;
    create table testbridge(col1 int);
    insert into testbridge values (1);
    insert into testbridge values (2);
    insert into testbridge values (3);
    commit;
    I have a connection called
    Connection Name With Space
    which I run the following in
    drop table testdbrige;
    create table testbridge(col1 int);
    insert into testbridge values (4);
    insert into testbridge values (5);
    insert into testbridge values (3);
    commit;
    Then in the system_local connection/worksheet I can run the following statement
    BRIDGE testbridge_remote as Connection Name With Space(select * from testbridge)
    +(SELECT * FROM testbridge_remote+
    MINUS
    SELECT * FROM testbridge
    +)+
    UNION ALL
    +(SELECT * FROM testbridge+
    MINUS
    SELECT * FROM testbridge_remote
    +);+
    It works ok.
    Returning rows in the remote table not in the local table , and rows in the local table not in the remote table .
    Regards,
    Dermot
    SQL Developer Team.

  • How to compare two rows from two table with different data

    how to compare two rows from two table with different data
    e.g.
    Table 1
    ID   DESC
    1     aaa
    2     bbb
    3     ccc
    Table 2
    ID   DESC
    1     aaa
    2     xxx
    3     ccc
    Result
    2

    Create
    table tab1(ID
    int ,DE char(10))
    Create
    table tab2(ID
    int ,DE char(10))
    Insert
    into tab1 Values
    (1,'aaa')
    Insert
    into tab1  Values
    (2,'bbb')
    Insert
    into tab1 Values(3,'ccc')
    Insert
    into tab1 Values(4,'dfe')
    Insert
    into tab2 Values
    (1,'aaa')
    Insert
    into tab2  Values
    (2,'xx')
    Insert
    into tab2 Values(3,'ccc')
    Insert
    into tab2 Values(6,'wdr')
    SELECT 
    tab1.ID,tab2.ID
    As T2 from tab1
    FULL
    join tab2 on tab1.ID
    = tab2.ID  
    WHERE
    BINARY_CHECKSUM(tab1.ID,tab1.DE)
    <> BINARY_CHECKSUM(tab2.ID,tab2.DE)
    OR tab1.ID
    IS NULL
    OR 
    tab2.ID IS
    NULL
    ID column considered as a primary Key
    Apart from different record,Above query populate missing record in both tables.
    Result Set
    ID ID 
    2  2
    4 NULL
    NULL 6
    ganeshk

  • 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

  • Installation issue - using a remote server without using remote desktop or citrix

    Hello Experts..
    We have a client who wants to install SAP Client (SAP 9 PL 11) in their local machines, but connecting to a remote server. They want to avoid connecting through Remote Desktop or Citrix.They already installed SAP clients in local pc's and when they select the server, they already configured it to a server located overseas. We succed on achieve the connection, but the performance is really poor (sometimes it takes about 2 minutes to open a simple menu in SAP).
    We ran internet speed tests in the client's office and in the server, and both results were more than satisfactory. But we couldn't come up with a reason for this enviroment works properly..
    The question is... Is this kind of enviroment supported by SAP?? Do you know about any alternative to connect from the local PC to a remote server without using remote desktop or citrix??
    Thanks in advance...
    Raúl Fragueiro

    Hi,
    I assumed you are using VPN connection right?
    In your scenario that is normal since the GUI of SAP B1 is not built for type of connection compare
    to SAP ERP GUI.
    The only SAP supported type of remote connection is either Terminal Server or Citrix.
    In our own scenario we are using Terminal Server and we are very satisfied. We have used
    this between to different cities. This is also prevents data corruption cause by intermittent
    internet connection.
    Hoping you will be convinced of using Terminal Server or Citrix.
    By the way, a quick question, why are you hesitant to use RDC or Citrix?
    For overview, if your remote requirement is just simple and basic you may use Terminal Server.
    The implementation of  this is very fast and simple also, what you need is only a license.
    If complex and advance features connection requirement connection use Citrix.
    For better understanding you may search from the site for the difference of the two.
    Thanks.
    Regards,
    Clint

  • Compare two table columns

    hi all,
    i am using db10g.
    my task is to compare two table's data for example
    table1 is having
    col1 col2 col3
    a b c
    e f g
    table2 is
    col4 col5 col6
    a e c
    e f g
    so i have to compare col1 first record and col4 first record.
    in otherwords first table first column first item with second table first table first value and so on.
    for ex: a= a
    b= e
    c= c etc
    how can i acheive this?
    both are database tables.
    i cannot use minus function because data types are different for the corresponding column
    how can i compare it?
    Thanks..
    Edited by: user13329002 on Jan 13, 2011 1:09 AM

    Hi,
    Try this
    select
        case
            when a.col1 = b.col1 then 'EQUAL' else 'NOT EQUAL' end column1,
        case
            when a.col2 = b.col2 then 'EQUAL' else 'NOT EQUAL' end column2,
        case
            when a.col3 = b.col3 then 'EQUAL' else 'NOT EQUAL' end column3 
    from (select col1,col2,col3,rownum rn from table1) a,
                                (select col1,col2,col3,rownum rn from table2) b where a.rn = b.rn Try to see how you order the rows of the two tables.
    cheers
    VT

  • COMPARE TWO TABLES

    HI,
    How to compare two tables in ODI.I want to extract UNMATCHED data in the two tables without using procedures,views.

    Hi,
    these tables has the exactly same ddl or the comparacion will be based on PK (or UK)?

  • How to compare two tables in SSIS?

    I am creating an SSIS package that will compare two tables and then insert data in another table.
    Which tool shall I use for that? I tried to use "Conditional Split" but it looks like it only takes one table as input and not two.
    These are my tables:
    TABLE1
    ID
    Status
    TABLE2
    ID
    Status
    TABLE3
    ID
    STatus
    I want to compare STATUS field in both tables. If Status in TABLE1 is "Pending" and in TABLE2 is "Open" then insert this record in TABLE3.

    You can use MERGE command , Sorry cannot test it right now.
    MERGE INTO tbl3
    USING (SELECT tbl2.ID, tbl2.status,tbl1.status as st1  FROM tbl1 JOIN tbl2 ON tbl1.ID=tbl2.ID) AS t ON T.ID=tbl3.ID 
    AND t.status='OPEN' AND t.st1='pending'
    WHEN NOT MATCHED 
    INSERT (status) VALUES (t.status)
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to add byte[] array based Image to the SQL Server without using parameter

    how to add byte[] array based Image to the SQL Server without using parameter.I have a column in table with the type image in sql and i want to add image array to the sql image column like below:
    I want to add image (RESIM) to the procedur like shown above but sql accepts byte[] RESIMI like System.Drowing. I whant that  sql accepts byte [] array like sql  image type
    not using cmd.ParametersAdd() method
    here is Isle() method content

    SQL Server binary constants use a hexadecimal format:
    https://msdn.microsoft.com/en-us/library/ms179899.aspx
    You'll have to build that string from a byte array yourself:
    byte[] bytes = ...
    StringBuilder builder = new StringBuilder("0x", 2 + bytes.Length * 2);
    foreach (var b in bytes)
    builder.Append(b.ToString("X2"));
    string binhex = builder.ToString();
    That said, what you're trying to do - not using parameters - is the wrong thing to do. Not only it is insecure due to the risk of SQL injection but in the case of binary data is also inefficient since these hex strings are larger than the original byte[]
    data.

  • Compare two tables and log the difference

    Hi,
    I want to compare two tables and log the difference in new table with the fields as (old value,new value, column name). The column name should be the changes value column

    Can you show an example?
    SELECT Foo.*, Bar.*
       FROM Foo
            FULL OUTER JOIN
            Bar
            ON Foo.c1 = Bar.c1
               AND Foo.c2 = Bar.c2
               AND Foo.cn = Bar.cn
     WHERE Foo.key IS NULL 
        OR Bar.key IS NULL; 
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to compare two database on different servers

    hi,
    I want to compare two database on different servers in oracle.first i want to ckechk thier structures and then data.i m using oracle 10.2.0.plz help me out
    Thanks in advance

    In terms of structures, there are various tools out there that can do this, such as TOAD which can do a database compare.
    In terms of data comparisons, that will depend on what sort of results you are expecting to see. I'm sure some tools will do it for you, but it can be just as easy to write your own comparison using a database link from one database to the other.

  • Join two table in different instance

    Hi,
    I have two table in different instance .
    IMEI in instance A
    RCA_SMART_CARD in instance B
    Below is the desc table :
    SQL> desc RCA_SMART_CARD;
    Name Null? Type
    N_CARD_ID NOT NULL NUMBER(10)
    C_CARD_SERIAL_NUMBER NOT NULL VARCHAR2(20)
    C_SIM_MSISDN VARCHAR2(20)
    C_SIM_IMSI VARCHAR2(20)
    C_LINKED_CARD VARCHAR2(20)
    N_PRO_IDENTIFIER NOT NULL NUMBER(4)
    C_CARD_TYPE VARCHAR2(1)
    N_SIM_STATE NUMBER(1)
    N_EEPROM_SPACE_LEFT NUMBER(9)
    N_VOLATILE_SPACE_LEFT NUMBER(9)
    N_NONVOLATILE_SPACE_LEFT NUMBER(9)
    N_CARD_OPTI NOT NULL NUMBER(15)
    N_PRODUCT_ID NUMBER(10)
    D_CREATION_DATE DATE
    D_MODIFICATION_DATE DATE
    D_STATUS_MODIFICATION_DATE DATE
    SQL> desc IMEI;
    Name Null? Type
    MSISDN NOT NULL VARCHAR2(20)
    IMEI NOT NULL VARCHAR2(16)
    DATE_MOD NUMBER(13)
    IMSI VARCHAR2(18)
    ICCID VARCHAR2(20)
    T_PROF RAW(20)
    EXTRA_DATA VARCHAR2(100)
    If I want to join two table together .
    I want to search the number of record in IMEI that have N_SIM_STATE =1 in RCA_SMART_CARD .
    The MSISDN in IMEI is equal to C_SIM_MSISDN in RCA_SMART_CARD .
    How can I do and what is the sql statment ??
    Please advice .

    First you need to decide, from where you want to execute the query.
    Let us assume it is instance A(as per your example).
    Then what you need to do is:
    1.     Create database link to instance B
    *[url http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_5005.htm]Here* is the semantics.
    2.     After creating the database link to instance B, you can achieve the result set by running the below query:
            SQL> select count(*) from IMEI t1 join RCA_SMART_CARD@<db_link_name> t2 on t1.MSISDN = t2.C_SIM_MSISDN where t2.N_SIM_STATE = 1
            Hope it helps!
    Cheers,
    AA

  • Comparing two tables

    how to compare two tables between two systems ?

    hi sravan, u can go to t/c OY19 to compare the two tables.
    Choose Manual selection
    Enter the name of the table that you want to compare
    Choose Execute
    in the next screen you have to give the description and RFC connection name which will make the link between two clients.
    Regards...
    Arun.
    Reward points if useful.

Maybe you are looking for

  • Installing iTunes 7.5 on Windows XP Professional 64bit

    I recently received an iPod Nano for Christmas. When I plugged it in, the version of iTunes I was using informed me that I had to upgrade to a new version of iTunes to support this iPod. I installed version the package of iTunes 7.5 and whatever vers

  • By pass authentication obiee 11g

    How to bypass the authentication in obiee 11g? I could not seeAUTHENTICATION_TYPE=BYPASS_NQS in NQSConfig.ini file. Thanks, Surya

  • Account closed - how do I get my credit back?

    I have left the UK and closed my BT account at the end of April 2009. I received the last bill at my new address abroad. My account was in credit and I should have received a cheque but never did. I called BT 8 times in the last 9 months and they alw

  • Basic 3d Filter

    Im creating a motion project and i want to use the 3d video filter to rotate an object with something on the back but i need to know what kind of image will i be able to use for the backside image

  • How implement a gallery into another html page?

    Hi, I am trying to add a few things around the actual gallery but I'm having a pretty hard time figuring out how. It's a navbar and some texts, etc. The problems are e.g. that it's as if there isn't any way to give the gallery a fixed width, the main