How to delete the double records connected to one or more than one tables in SQL 2008?

Hi
Can anyone please help me with the SQL query. I Im having a table called People with columns names: personno., lastname, firstname and so on. The personno. is having duplicate records,so all the duplicate records i have written with "double" in
the beginning of the numbers. I tried deleting these double records but they are linked to one or more than one tables. I have to find out, all the tables blocking the deleting of double person. And then create select statements which creates update statements
in order to replace the current id of double person with substitute id. (The personno. is in the form of id's in the database)
Thanks

You should not append "double" in the personno. When we append it will not be able to join or relate to other table. Keep the id as it is and use another field(STATUS) to mark as duplicate. Also we will require another field(PRIMARYID) against
those duplicate rows i.e the main or the primary personno.
SELECT * FROM OtherTable a INNER JOIN
(SELECT personno, status, primaryid FROM PEOPLE WHERE status = 'Duplicate') b
ON a.personno = b.personno
UPDATE OtherTable SET personno = b.primaryid
FROM OtherTable a INNER JOIN
(SELECT personno, status, primaryid FROM PEOPLE WHERE status = 'Duplicate') b
ON a.personno = b.personno
NOTE: Please take backup before applying the query. This is not tested.
Regards, RSingh

Similar Messages

  • How to set the Certifcate to use for SSL when more than one available?

    I apologise for bad wording of question.
    We have a 11g Directory Server and when we created the directory instance it generated a self-signed certificate. very nice.
    We have recently requested and installed a CA signed certifcate, so we now have TWO certificates in the directory certificate store. Default Certificate and the new Server-Cert (the CA signed one)
    LDAP clients STILL seem to be presented with the self-sgned certificate though.
    Simple question... how do I make my Server-Cert the 'default' certificate presented to LDAP clients ???
    I would rather not delete the self-signed cert if possible.
    I cant find any documented method to achieve this.

    # Listing Certificate
    $ /certutil -L -d <path>/slapd-abc/alias -P slapd-
    # Add Trust by adding CT
    $ certutil -M -n "GeoTrust DV SSL CA" -t CT,, -d <path>/slapd-abc/alias -P slapd-
    # Verify the setup.
    $ certutil -L -d <path>/slapd-abc/alias -P slapd-
    ( You should see the CT beside the relevant cerficate, making it default for SSL communication )
    GeoTrust DV SSL CA CT,,
    Link : http://docs.oracle.com/cd/E19656-01/821-1504/6nmg10b6g/index.html ( Look around for different steps for configuring SSL )
    JPrince

  • How to Delete the condition record in CRM

    HI,
    Can you please help me how to delete the condition record from condition table in CRM.
    Please explain the usage of FM CRMXIF_CONDITION_SEL_DELETE with examples.
    I have also read the documention of the function module. How to use this FM for custom defined condition table.
    (this is the code given in Documentation)
    DATA-OBJECT_REPRESENTATION         = 'E'
    DATA-SEL_OPT-CT_APPLICATION              = 'CRM'
    DATA-SEL_OPT-OBJECT_TASK                    = 'D'
    DATA-SEL_OPT-RANGE-FIELDNAME        = 'PRODUCT_ID'
    DATA-SEL_OPT-RANGE-R_SIGN                  = 'I'    (Including)
    DATA-SEL_OPT-RANGE-R_OPTION           = 'EQ'
    DATA-SEL_OPT-RANGE-R_VALUE_LOW  = 'PROD_1'
    Thanks
    Shankar

    Hi Shankar,
    I am using the same CRMXIF_CONDITION_SEL_DELETE function module to delete condition record present in CRM.
    But it is giving me below error in the return table of the FM after i run the program. Can you please correct me if I am doing any thing wrong?
    Error in  lt_return: SMW3     CND_MAST_SEL_DEL_EXT_VALIDATE     CND_M_SD
    code:
    ls_range-fieldname = 'PRODUCT_ID''.
    ls_range-R_SIGN = 'I'.
    ls_range-R_OPTION = 'EQ'.
    ls_range-R_VALUE_LOW = '123456'.
    APPEND ls_range TO lt_range.
    MOVE lt_range TO ls_entry-SEL_OPT-range.
    ls_data-SEL_OPT-object_task = 'D'.
    ls_data-SEL_OPT-ct_application = 'CRM'.
    ls_data-object_representation = 'E'.
    CALL FUNCTION 'CRMXIF_CONDITION_SEL_DELETE'
      EXPORTING
        DATA          = ls_date
    IMPORTING
       RETURN        = lt_return
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      IMPORTING
        return = lt_ret.
    Edited by: Saravanaprasad Nadar on Jul 7, 2010 1:27 AM

  • HT1473 How may one add cover art in iTunes 11, for a CD imported to the library? How may one add more than one images?

    How may one add cover art in iTunes 11, for a CD imported to the library?
    How may one add more than one images?

    I understand what you mean - I too, would like to see some variability in the 'default'. Besides having a single default, I would step that up to a default that changes with genre and media: ie. I could see using a sax for Jazz; a microphone for a Podcast, etc.
    I don't have the answer to your question yet, but I think I'm going to crack open the iTunes package to see what default images there are embedded in there.

  • How to exclude one or more than one member on report?

    Post Author: izhar
    CA Forum: WebIntelligence Reporting
    Hi all group members, I am working on BOXI R2. I have to ask that, How to exclude one or more than one member from the report. I know there is function of filter, through which we can see our desired members and other remaining will be excluded, but that's filter. In some of tools i have seen just do right click on a specific member and click on "Exclude" option to exclude the member. Suppose i have placed a Time dimension on the report and standing on "Month Level" which has data from 1, 2, ... 7,8, ... 11, 12 Now i just have to exclude member 7 from the report. Can any member guide me here. Regards, Izhar

    Post Author: jsanzone
    CA Forum: WebIntelligence Reporting
    Izhar,
    If you run the report in "modify" mode, then you have two options
    1) You can click on the "Show/Hide Filter Pane" button which opens up the "apply filter" pane.  From there you go to your Data panel and grab, drag, and drop an item from the Data panel into the apply filter pane and provide a constant or select a value to filter in or out from your report.
    2) You can highlight the column of data that you want to filter on, then click on the "Add Quick Filter" button.  Using the List of Values menu you either select one or multiple items that you want to include in the report.

  • How to select a substring in oracle up to a more than one specific character

    How to select a substring in oracle up to a more than one specific character
    for ex : 121.051^NP: FAMILY PRACTICE  ( trim the values before ^ )
                121.051^*NP: FAMILY PRACTICE (trim the value before *).
    with below function I can only get rid of ^ , I want both the specific characters ^ and ^* to be removed at the same time.   
    SUBSTR(p.phys_sub_grp_2_desc,INSTR(p.phys_sub_grp_2_desc, '^') +1)

    Another option is to boldly replace 'em:
    SQL> with t as (
      2  select '121.051^NP: FAMILY PRACTICE' str from dual union
      3  select '121.051^*NP: FAMILY PRACTICE' from dual
      4  )
      5  --
      6  -- actuel query:
      7  --
      8  select substr( replace(str, '*')
      9               , instr(replace(str, '*'), '^')+1
    10               ) str
    11  from   t;
    STR
    NP: FAMILY PRACTICE
    NP: FAMILY PRACTICE
    2 rows selected.

  • Why cant I connect address book to more than one email account.

    Why cant I connect address book to more than one email account I have 3 but can only do this for my icloud account ??  I am using the correct pass word but still no joy ????

    I bought an iPhone 3G this morning (wahoo!), and can confirm that I have setup both an IMAP (for my home server) and an exchange server (for work).
    Exchange is set to push email (so will get email as it arrives) and IMAP is currently set to manual, and is working like a charm.. With multiple accounts you get to set one as the preferred which it will default to when composing (but you can change the accounts on the compose screen)
    Only minor annoyance is signature is shared between both accounts, other than that am loving it!

  • How to use my creative cloud account, downloading apps, to more than one computer, i.e. my desktop and laptop?

    How to use my creative cloud account, downloading apps, to more than one computer, i.e. my desktop and laptop?

    Just download the CC manager to the machines an sign in thru it.
    Creative Cloud Help / Install, update, or uninstall apps
    http://helpx.adobe.com/creative-cloud/help/install-apps.html
    Creative Cloud Learn & Support
    http://helpx.adobe.com/creative-cloud.html
    Creative Cloud / Common Questions
    http://helpx.adobe.com/creative-cloud/faq.html

  • TS3276 As an email is being send the mail activity indicator is showing that more than one email is being send....what is going on here? Thanks

    Question: As I send an email, the mail activity indicator is showing that more than one email is being sent! Last time it was 5 even though I was only sending one and there were no other emails in the out box! What's going on here I ponder?

    Several time in the past, similar question was asked in the forum, for example check the link and reference OSS notes mentioned in it. You can also search the forum, if you need further info on this topic.
    http://scn.sap.com/thread/3230103
    Regards,

  • How to delete the single record from the  ODS

    HI,
       I want to DELETE  the particular record from ODS.. how to delete that..
    plz give me the solution.. it's urgent..
    with regards
    @jay

    Hi Prakash,
        You can delete a particular record from ODS by specifying the key field name in Selective deletion button available in Contents tab in the manage screen of ODS. But it will only delete the record from the active data table and not from the Change log and new data table . You should be very carefull if you are doing in Production system as there is chance of deleting other records accidentally.
    Go to Selective deletion button - > Click on delete selection -> Enter the key field values of the record you want to delete-> Press save button to save as Variant -> Go back and click on selection button -> Chosse the background job type -> Click on start button.
    Regards,
    Prakash

  • How to delete the matching records from two internal tables

    Hi ,
    I have two internal tables say A and B of the same type. If A has 10 records and B has 4 records , I want to delete the 4 records in B from A .
    loop at B into wa .
    delete A where key = wa - key .
    endloop.
    takes a long time if the table B is huge. how can I improve the performance.
    Thanks.
    Gayathri

    Hi Gayathri,
    You could try field-symbols. It reduces the data transfer from the internal table B to the work area.
    field-symbols <fs_itab_b> like line of B.
    loop at B assigning <fs_itab_b>.
      delete A where key = <fs_itab_b>?-key.
    endloop.
    Regards,
    <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=zwcc%2fwm4ups%3d">anand Mandalika</a>.

  • How to delete the material records related to storage type

    Dear SAP guru's,
    I got a situation that if the material "XXXXXX" exists in two different storage type (let say 001 & 002 ) and the material needs to be removed out of one (Let say 002) to avoid the picking and putaway in future.
    Inorder to accomplish an above requirement we tried the below cases
    Case 1: By flagged the material "XXXXXX" under storage type 002 in MM06 transaction.But it didn't restrict the system on allocating and removing the stock from /to to the storage type 002.
    Case 2:After we flagged the material for deletion under storage type 002 ,we used to MM71 transaction to archive & delete the material record that assocaited with the storage type 002 completely.
    I am kind of queiries to know if there is any other method or procedure available to delete the storage type associated material records in SAP.
    Please guide me with the other options.Thanks.
    Regards,
    John.

    Hi John,
    Its very simple, remove the Storage type indicators from the material master - Warehouse View 1 at Stock placement & Stock removal section, with this it won't pickup or place the materials in the concerned storage type.
    If you have extended this materials to more than 1 storage type, you need to do the same for all the storage types.
    Reward if it is helpful.

  • How to delete the duplicated records, not just surpress the records?

    I am new to CR. Right now I am doing a project which needs CR get query from Oracle. I got the query from Oracle. There are records with duplicated fields. For example (the following only show part of fields):
    ID    body_code  
    1            10            
    2             10            
    3             15            
    4              15           
    5              15           
    6              16           
    I need to only select records (not surpress, because I will do some caluculate later) like following:
    ID         body_code        
    1             10         
    2              15
    3               16   
    I tried to creat selection fomula in fomula workshop, shown as follows:
    onlastrecord;
    <>next
    but CR said next can be evaluated. I think it must have something to do with the print-time. So what show I do to delete the duplicated records.Thank you very much.

    Ting,
    Try this:
    Insert a group on body_code.  Then create a running total called Distinct Count.  Field to summarize -> ID, Evaluate on change of group Group # 1 Body Code, and Never Reset.
    Then insert a chart in the report header:
    In the advanced layout, select body_code on change of and select Distinct Count running total in the Show values.
    I hope I understood what you're looking to accomplish.
    Z

  • How to delete the duplicate records in a table without promary key

    I have a table that contains around 1 million records and there is no promary key or auto number coulums. I need to delete the duplicate records from this table. what is the simple effective way to do this.

    Please see this link:
    Remove duplicate records ...
    sqldevelop.wordpress.com

  • How to allow access to my airport extreme network for more than one wirelss device at the same time

    I received a Kobo Vox ereader for Christmas and have not been able to connect to my home wireless network. It works with unsecured networks and I tested it out at an Apple reseller with their airport extreme netwok and it connects fine.
    It seems as if I cannot have more than one wireless device connected to my home netork at the same time.
    So here is what I did to test this out:
    - I powered off the Kobo vox
    - I shut down my macbook
    - I turned off the modem and unplugged the power cord and removed the cable connection from the modem.
    -  I also unplugged the airport extreme router.
    - I waited for about 15 minutes and then set it all up again and turned on the power to the router and the modem
    - I turned on the kobo  vox (I left my laptop shut down)
    - my kobo vox was able to connected to the internet.
    - I powered up my laptop and it couldn't connect to the internet.
    So, I went through the above steps again and powered up my laptop first and was able to connect to the internet. I then turned on my Kobo and was not able to connect.
    It seems as if I can only have one device connected to my wireless network at one time and that device is the first one to be powered on and connected to the internet.
    Am I missing some network or airport extreme settings...
    thanks

    Try the following on your Mac.....
    Open Macintosh HD > Applications > Utilities > AirPort Utility
    Click Manual Setup
    Click the Internet icon
    Click the Internet Connection tab
    Change the setting for Connection Sharing to read Share a public IP address
    Click Update

Maybe you are looking for

  • Can I get an iTunes/app store receipt re-sent to me?

    I recently got an iPhone 6, and had to reinstall password keeper, but password keeper is saying i have no account with them under my two emails. I have been using password keeper for 3 years and pay $10/year to have the feature of backing up my passw

  • Report on Campaign-Recipients.

    Hi, Im trying to track the no of contacts who attended campaign,received the campaign invite & who declined/did not attend the campaign. Also from the no. of contacts who attended the campaign, how many actually got converted to leads. Help required

  • Is there any way i can leave a suggestion for apple products

    i would like to know why are we as the customers of apple not given the option to switch between pc's and manage music,videos , etc.on to different itunes with our i phones in my paticular situation the iphone 5 i would like to know if its possible t

  • How do I restore a chart I deleted from the Summary Report?

    I inadvertently deleted a question from the Summary Report by clicking the little trash can icon and I'd like to get it back. To clarify: the question is still there on the form; I'm just looking to restore the chart on the report. Thanks!

  • Selection tool doesnt work in illustrator cc 2014

    selection tool doesnt work in illustrator cc 2014.