To find difference in table in two table

Hi,
I have a table 'A' and table 'A_repository'. Both have same column.Only difference is that table A has column ID as primary key and there is no primary or foreign key table A_repository.
In table A, for ID=1 has data. Also for table A_repository, ID=1 has data but data in  few columns in table A_repository is different from table A for ID=1.
How can I know which column has different data for above senario and what is the different data( means what is data in that column for both the table).
Please give some idea.
Thanks,
Chandru

Check Comparing the Contents of Two Tables in Ask Tom: On Injecting and Comparing to find out differring rows efficiently.
Regards
Etbin

Similar Messages

  • How to find difference in amount between two fields in two different tables

    Hi,
    I am new to PL/SQL. I need to write a procedure to calculate the difference between two columns of two seperate tables. For example:
    I have Table a and Table b. Both with two columns Id and Amount. I need to find the difference of Amount between table a and table b value for each record in table b, store it in variable and then do further operations using that difference. Kindly help me with this.

    Something like this?
    INSERT INTO table_c (id, diff, p_or_n)
    SELECT
    a.a_id,
    a.a_value - b.b_value
    DECODE( SIGN(a.a_value - b.b_value),
      1 , 'P',
      0 , 'P',
      -1, 'N'
    FROM table_a a JOIN table_b b
    ON (a.a_id = b.b_id);
    -- Ranit

  • Finding difference of Hours between two dates

    I need logic to find the difference of number of hours between any two dates excluding saturdays & sundays. Please provide PLSQL code.

    my dear
    this is the pl/sql to create on db.
    | | This function it will created on the data if you like.
    | | the input parameter for this function is two date .
    | | you can add more feature on it because turn it felixable eg.
    | | you can execlude varaible days from paramteres....
    CREATE OR REPLACE FUNCTION GET_HOURS(P_FROM_DATE IN DATE ,
    P_TO_DATE IN DATE DEFAULT SYSDATE ,
    P_EXECLUDE IN VARCHAR2 DEFAULT '17' ) RETURN NUMBER IS
    V_CURR_DATE DATE := P_FROM_DATE ;
    V_ALL_DAYS NUMBER := 0 ;
    V_NET_HOURS NUMBER := 0 ;
    V_FROM_JUL NUMBER := TO_CHAR(P_FROM_DATE,'J');
    V_TO_JUL NUMBER := TO_CHAR(P_TO_DATE,'J');
    BEGIN
    FOR R IN V_FROM_JUL..V_TO_JUL LOOP
    IF INSTR(P_EXECLUDE,TO_CHAR(V_CURR_DATE,'D')) = 0 THEN
    V_ALL_DAYS := V_ALL_DAYS + 1 ;
    END IF;
    V_CURR_DATE := V_CURR_DATE+ 1 ;
    END LOOP;
    V_NET_HOURS := V_ALL_DAYS * 24 ;
    RETURN(V_NET_HOURS);
    END;
    -- this is for test senario
    SELECT GET_HOURS(SYSDATE-30) FROM DUAL ;
    SELECT GET_HOURS(SYSDATE-30,SYSDATE,'127') FROM DUAL;
    SELECT GET_HOURS(SYSDATE-30,SYSDATE,'0') FROM DUAL; -- to execlude zero days.

  • Find Differences between two tables at column level

    Hi,
    I have 2 tables one live table and the other History table..
    If i have to find differences between live table and the latest version in the History table and also find which column got chaanged
    How would i do that for a table which has many columns and i need each column for which the value has changed for a id
    for ex:
      Table 1   (LIve)                           Table 2 (History)
    ID col1     col2    Version               ID       col1     col2    Version
     1   ABC     123     V1                     1       ABCD   123     v2
     2   NBS     1234   V1                     2        NBS     123     V2
    Result set should be 
    Result Set:
    ID col which changed
    1    col1
    2    col2   
    Because the values for that column had been changed
    Except gives me all the differences not just the column level ..

    The dynamic version using schema views... :D
    --Build a coulple OF testing tables to play with
    CREATE TABLE dbo.Table1 (
    ID INT IDENTITY(1,1) PRIMARY KEY,
    Col1 INT,
    Col2 INT,
    Col3 INT
    CREATE TABLE dbo.Table2 (
    ID INT IDENTITY(1,1) PRIMARY KEY,
    Col1 INT,
    Col2 INT,
    Col3 INT
    INSERT dbo.Table1 (Col1,Col2,Col3) VALUES
    (123,456,789),
    (111,222,333),
    (444,555,666),
    (777,888,999),
    (321,345,769),
    (179,753,758),
    (362,362,236),
    (856,874,896),
    (821,729,324)
    INSERT dbo.Table2 (Col1,Col2,Col3) VALUES
    (123,456,789),
    (111,999,333), --col2 diff
    (444,555,666),
    (777,888,999),
    (321,345,123), --col3 diff
    (179,753,758),
    (362,362,236),
    (234,874,896), --col1 diff
    (821,729,324)
    And then the actual solution...
    DECLARE
    @t1 VARCHAR(10) = 'Table1',
    @t2 VARCHAR(10) = 'Table2'
    IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP TABLE #temp
    SELECT
    c.TABLE_SCHEMA,
    c.TABLE_NAME,
    c.COLUMN_NAME,
    c.ORDINAL_POSITION,
    CASE WHEN u.COLUMN_NAME IS NOT NULL THEN 1 ELSE 0 END AS PK
    INTO #temp
    FROM
    INFORMATION_SCHEMA.COLUMNS c
    JOIN INFORMATION_SCHEMA.TABLES t
    ON c.TABLE_NAME = t.TABLE_NAME
    AND c.TABLE_SCHEMA = t.TABLE_SCHEMA
    LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE u
    ON c.COLUMN_NAME = u.COLUMN_NAME
    AND c.TABLE_NAME = u.TABLE_NAME
    AND c.TABLE_SCHEMA = u.TABLE_SCHEMA
    AND OBJECTPROPERTY(OBJECT_ID(constraint_name), 'IsPrimaryKey') = 1
    WHERE 1 = 1
    AND t.TABLE_TYPE = 'BASE TABLE'
    AND c.TABLE_NAME IN (@t1,@t2)
    ORDER BY
    c.TABLE_SCHEMA, c.TABLE_NAME, c.ORDINAL_POSITION
    DECLARE @select VARCHAR(MAX)
    SELECT @select = COALESCE(@select + ', ', '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME + '.' + t.COLUMN_NAME
    FROM #temp AS t
    ORDER BY t.TABLE_NAME, t.ORDINAL_POSITION
    DECLARE @from VARCHAR(MAX)
    SELECT @from = COALESCE(@from + ' FULL JOIN ', '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME
    FROM #temp AS t
    WHERE t.PK = 1
    ORDER BY t.TABLE_NAME
    DECLARE @on VARCHAR(MAX)
    SELECT @on = COALESCE(@on + ' = ', '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME + '.' + t.COLUMN_NAME
    FROM #temp AS t
    WHERE t.PK = 1
    ORDER BY t.TABLE_NAME, t.ORDINAL_POSITION
    DECLARE @where VARCHAR(MAX)
    SELECT @where = COALESCE(@where + CASE WHEN t.TABLE_NAME = @t1 THEN ' OR ' ELSE ' <> ' END, '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME + '.' + t.COLUMN_NAME
    FROM #temp AS t
    WHERE t.PK = 0
    ORDER BY t.ORDINAL_POSITION, t.TABLE_NAME
    DECLARE @sql VARCHAR(MAX) = '
    SELECT ' + @select + '
    FROM ' + @from + '
    ON ' + @on + '
    WHERE ' + @where
    EXEC (@sql)
    HTH,
    Jason

  • How can I get the difference of  tables between two oracle server?

    We team have 2 oracle servers in the same version.
    one is develop server and the other is priduct server.
    I want to know what is difference in tables define between the two oracle servers.
    give me a method or a step or a sql script or a tool to compare these two set of tables.
    Edited by: Oracle-Sunmeng on Aug 1, 2012 6:36 PM

    Hi Sunmeng,
    Does Database Link exists between Databases ??
    If I am Clear, Are you looking Something like this.
    To Identify the tables difference, you can query the USER_TAB_COLUMNS view.
    SELECT DISTINCT table_name, 'User1' AS user_table
               FROM user_tab_columns
    UNION ALL
    SELECT DISTINCT table_name, 'User2' AS user_table
               FROM user_tab_columns@dblink
           ORDER BY 1;Which gets us all the Tables available in Both User. where you can filter based on what
    you require.
    Similary, you for column difference
    SELECT   table_name, column_name, 'User1' AS user_table
        FROM user_tab_columns
    UNION ALL
    SELECT   table_name, column_name, 'User2' AS user_table
        FROM user_tab_columns@dblink
    ORDER BY 1;If you need to count the no of columns in both Tables of different databases. Then try this,
    SELECT table_name, 'User1' user_name,
           (SELECT MAX (column_id)
              FROM user_tab_columns a
             WHERE a.table_name = b.table_name) colno
      FROM user_tables b
    UNION ALL
    SELECT table_name, 'User2' user_name,
           (SELECT MAX (column_id)
              FROM user_tab_columns@dblink a
             WHERE a.table_name = b.table_name) colno
      FROM user_tables@dblink b;And, what the Columns in both tables may be same but, if datatype and length of column differs ?????
    Thanks,
    Shankar
    Edited by: Shankar Viji on Aug 1, 2012 10:47 PM
    Edited by: Shankar Viji on Aug 1, 2012 10:49 PM

  • What is difference between table space and shchema

    what is difference between table space and shchema ?

    784633 wrote:
    so each user has it own space of tables - schema ?yes, but let's clarify a bit ....
    The "schema" is the collection of all objects owned by a particular user. So if user SCOTT creates two tables, EMP and DEPT, and a view EMP_RPT, and a procedure GET_MY_EMP, those objects (tables, views, procedures) collectively make up the SCOTT schema.
    Those objects will be physically stored in a tablespace.
    A tablespace is a named collection of data files. So tablespace USERS will be made up of one or more data files. A specific datafile can belong to one and only one tablespace. If a tablespace has more than one data file, oracle will manage those files as a collection invisible to the application - much like the OS or disk subsystem handles striping across multiple physical disks.
    A specific object in the SCOTT schema can exist in only one tablespace, but not all objects of the schema have to be in the same tablespace. Likewise a tablespace can contain objects from multiple schemas.
    and can one user to access tables of other users?As others have said - FRED can access tables belonging to SCOTT as long has SCOTT has granted that access to FRED.

  • To find out the table which gives me the vendor no. to whom i pay brokerage

    Hello Everyone!
          My question is,
               In PO i have two different vendors... one vendor is the one from which we purchase goods and second vendor is the one to whom we pay brokerage. We mention the brokerage amount in 'ZBR0' condition type. Now I want to find out the table which gives me the vendor no. to whom i pay brokerage.
               Please its so urgent.
          Thanks & Regards,
                    Pranil Shinde.

    Hi,
    look in table KONV and you will find your condition and the vendor.
    Regards Vassko!

  • Unable to find header & Item table name

    Hi PP Team,
                         I am very confused to find table name like BOM header,production header or item i know table name BOM header is STKO,& Order header AFKO.As per procedure am go to header press F1 i got table name but not header or item table name.
    Could you plz explain me process how to find this table name.
    Kindly assist me on above problem.
    Regards,

    Dear 87,
    DOGBOY49 has explained it very beautifuly,
    there is difference in table name and field,
    Put cursor in screen field, press F1, it will show description about this field. Then press "Technical Information" button, you can get field name and table / structure / view. If you get a table / view field, check the data in table / view, you may find it there.
    Exploring Search help (display available list to help input value by pressing F4 in screen field).
    Sometimes field with search help can be found be displaying field in its search help. Example, tcode XD03 (display customer) field Customer (RF02D-KUNNR). It is a stucture field, to find the table, place cursor in screen field, press F4 (display search help), run search help until it show available list. In this list, place cursor in field customer, then press F1 to display technical info. You will get table/view field for this
    Above all this there is help available at
    www.sap-topjobs.com/SAPTABLEREF%5B1%5D.doc
    Google and of course SDN guru's
    Cheers....
    Rahul.....
    Edited by: Rahul Vijay Pande on May 7, 2011 9:02 AM

  • Query on differences between table Icons and types in smartforms

    Hello,
    I have a question regarding the apparent differences between tables in smartforms.
    I have noticed on some of the default smartforms that are supplied the table icon is the same as on the
    'Create new session' button at the top of a Sap session window. The icon on a table that I am currently working on is like a 'spread sheet' design, a heading with columns, as shown in the current documentation. The way the  two styles of tables work is different.
    Is the difference down to the fact one was created in an older implementation of Sap?
    The reason I ask is because the table I refered to initially, is easier when configuring cells.
    Regards
    Mike.

    Hello Karthik
    Thanks for taking the time to reply to my question.
    The difference in the icons but with essentially the same function has always confused me since starting Smartforms.
    Thank you for enlightening me.
    I asked the question because the Complex node has a feature that I could have used. I have managed though to solve my problem using a table node.
    Ten points awarded.
    Best Regards
    Mike Spear.

  • How do i find out the tables (data)effected in a schema after a particular time stamp

    how do i find out the tables (data not structure)effected in a schema after a particular time stamp?
    pls email in [email protected]

    You can't do that. That would be a real security risc.
    /KAj

  • How do i find out the tables effected in a schema after a particular time stamp

    how do i find out the tables effected in a schema after a particular time stamp?
    pls email in [email protected]

    If you are doing a reload every time then you can issue following commands to clear data from cube.
    lmt name to all
    allstat
    clear all from <cubename>prttopvar
    You can wrap above commands in pl sql procedure using dbms_aw.execute package and execute it before cube load starts. Instead of clearing it from whole cube you can clear only from one partition also. Just take a look at clear command in olap DML 10.2 reference.
    Thanks,
    Brijesh
    Edited by: Brijesh Gaur on Aug 10, 2010 6:47 AM

  • How to find out which table store historical data for V_T001B?

    dear all,
    how i want to trace and find out which table that store all maintenance data history from V_T001B?
    thanks.

    i already find out into both table... but the data not store there...

  • How to find out the tables from extract structures

    Hi All,
    As I know my data sources are 2lis_04_p_matnr,2lis_04_p_comp,2lis_04_p_arbpl.
    How to find out the tables concerned with the fields in the extract structure.
    Thanks

    Pl check this link:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/29/79eb3cad744026e10000000a11405a/frameset.htm
    OR navigate to: help.sap.com - netweaver - bi content - supply chain - look for your application area and the extractor and you will see the source tables and fields.
    Ravi Thothadri

  • How to find out the table name

    hi,
    how to find out the table name in which the data from a particular structure in a particular screen is saved,
    please tell me the procedure to find out the table name for saving the structure data that is inputted at runtime.
    Thanks,
    chinnu

    Hi Chinnu,
    Below are the tables that are referred to find out the table names
    DD02L Table contains the SAP Tables.
    DD02T Table contains the SAP Table Texts.
    DD01L Table contains the Domains
    DD01T Table contains the Domain Texts.
    DD03L Table contains the Table Fields.
    DD03T Table contains the Table Field Texts. (Language Dependent)
    DD04L Table contains the Data Elements.
    DD04T Table contains the Data Element Texts.
    DD05s Table contains the Foreign Key Fields
    last words with L and T only. L->Database Fetch T-> Text
    And the procedure to retrive the table name is as follows
    1. Go to se11
    2. Enter table name DD03T and execute
    3. In the next screen you can find Tables, fields, test etc. there you can enter the field name in the fields 
      and execute.
    4. you can get all tables which contains the field.
    I hope this will solve your problem
    Regards,
    Chandru

  • How to find names of tables created by specific user

    I have tried;
    select * from dba_tables
    and
    select * from users_tables
    and it shows 1600 + and 900+ tables resp. I just need to find out the tables created by me.
    any help or guidance is greatly appreciated.

    Hi,
    Welcome to the forum. This may help you.
    select * from dba_objects where object_type='TABLE' and owner = <user>
    select * from user_objects where object_type='TABLE'cheers
    VT

Maybe you are looking for

  • Custome Process for update the date

    Hello Every one, I have a page with the check-box where the user can select a record and update the record by pressing on the button. I have three processes, and each of these process update one field ( which is a date field) of the page by pressing

  • Tips for Using Containment Relationships (When Are They Required?)

    Hello again, Our team was recently discussing when to use containment relationships, and we realized that there is room for improvement in our understanding. Having read many of the help topics, the primary use for containment relationships seems to

  • I can't open my games once i open they back in main menu.

    I can't open my games they always back in main menu.

  • Nokia 6280 Software Updater

    Hi, this is my fist topic, so sorry if I'll say something wrong. I read about 5.x firmware for Nokia 6280 phone, but I can't find this firmware on the update page. My phone has firmware version 3.40. Tnk's Andrea

  • Authorizing a new computer with a new ipod

    I sold my old Ipod, got a new pod along with a new computer. My question is how do I authorize this new computer along with getting all my old apps on my new ipod. I really don't want to pay for it all, all over again! Please someone help me! Thanks