How to remove numeric value in the fields of a table

Environment: SQL Server 2008R2
Tools: MSMS
Code:
a. Table Definition 
USE [DLPT_CMS1_RESTORE]
CREATE TABLE [dbo].[Mocha]
[id] [int] IDENTITY(80,1) NOT NULL,
[Login_ID] [char](10) NULL,
[PE4] [varchar](8000) NULL,
[PE9] [varchar](8000) NULL,
[PE11] [varchar](8000) NULL,
[PE15] [varchar](8000) NULL,
[PE17] [varchar](8000) NULL,
[PE20] [varchar](8000) NULL,
[PE22] [varchar](8000) NULL,
[PE25] [varchar](8000) NULL,
[PE28] [varchar](8000) NULL,
[PE29] [varchar](8000) NULL,
[PE27] [varchar](8000) NULL
b. data
Insert into Mocha (Login_ID,[PE4],[PE9] ,[PE11],[PE15],[PE17],[PE20],[PE22],[PE25],[PE28], [PE29],[PE27])
Values (293595,293595,293737,293737,293737,293737,293737,293737,'I dont think 12 week program is hard',293737,293737,'antiinflamatory- this helps to fight free radicals and ward off disease.')
Insert into Mocha (Login_ID,[PE4],[PE9] ,[PE11],[PE15],[PE17],[PE20],[PE22],[PE25],[PE28], [PE29],[PE27])
Values (293841,293841,293841,293841,'293841 I feel that the product should be more holistic'
,'293841 I would like for the customer support to give more immediate feedback'
,'293841 Fends off alzeimer disease and dementia. It has been proven to destroy the amaloid plaques that are believed to be a cause of dementia and memory loss',
293841,293841,293841,293841,293841,293841)
Challenge: 
1. Delete / Remove login_ids from a string found in one or more of the fields in Mocha table 
Example: the following string contains login_id '293841 I would like for the customer support to give more immediate feedback' , remove the login_id in the narrative field which could be PE4, PE22. or PE28
2. Count the response or narrative field for each column after the deletion is completed 
My script and still working progress
SELECT * FROM MOCHA
WHERE ISNUMERIC(PE4) = 1 and [PE4] like '%[0-9]%'
Thanks for the support

I added a new data which shows inaccurate results using your last updated code. The mistake appears in the 3rd row culomn name PE25 is null but counts it as 1 
CREATE TABLE [dbo].[Mocha]
[id] [int] IDENTITY(80,1) NOT NULL,
[Login_ID] [char](10) NULL,
[PE4] [varchar](8000) NULL,
[PE9] [varchar](8000) NULL,
[PE11] [varchar](8000) NULL,
[PE15] [varchar](8000) NULL,
[PE17] [varchar](8000) NULL,
[PE20] [varchar](8000) NULL,
[PE22] [varchar](8000) NULL,
[PE25] [varchar](8000) NULL,
[PE28] [varchar](8000) NULL,
[PE29] [varchar](8000) NULL,
[PE27] [varchar](8000) NULL
Insert into Mocha (Login_ID,[PE4],[PE9] ,[PE11],[PE15],[PE17],[PE20],[PE22],[PE25],[PE28], [PE29],[PE27])
Values (293737,293737,293737,293737,NULL,293737,NULL,293737,'I dont think 12 week program is hard',293737,293737,'antiinflamatory- this helps to fight free radicals and ward off disease.')
Insert into Mocha (Login_ID,[PE4],[PE9] ,[PE11],
[PE15],[PE17]
,[PE20],[PE22],[PE25],[PE28], [PE29],[PE27])
Values (293841,293841,293841,293841
,'293841 I feel that the product should be more holistic'
,'%%293841%% I would like for the customer support to give more immediate feedback'
,'%%293841%% Fends off alzeimer disease and dementia. It has been proven to destroy the amaloid plaques that are believed to be a cause of dementia and memory loss'
,293841,NULL,NULL,293841,293841)
Insert into Mocha (Login_ID,[PE4],[PE9] ,[PE11],[PE15],[PE17],[PE20],[PE22],[PE25],[PE28], [PE29],[PE27])
Values (293735,'293735 my name',NULL,NULL,NULL,NULL,NULL,NULL,'%%293735%%I dont think',293735,293735,'this helps to fight free radicals and ward off disease')
select
Replace(Replace(PE4,RTRIM(Cast(Login_ID as varchar(10))), ''),'%','') PE4
,Replace(Replace(PE9,RTRIM(Cast(Login_ID as varchar(10))), ''),'%','') PE9
,Replace(Replace(PE11,RTRIM(Cast(Login_ID as varchar(10))), ''),'%','') PE11
,Replace(Replace([PE15],RTRIM(Cast(Login_ID as varchar(10))), ''),'%','') PE15
,Replace(Replace(PE17,RTRIM(Cast(Login_ID as varchar(10))), ''),'%','')PE17
,Replace(Replace(PE20,RTRIM(Cast(Login_ID as varchar(10))), ''),'%','') PE20
,Replace(Replace(PE22,RTRIM(Cast(Login_ID as varchar(10))), ''),'%','') PE22
,Replace(Replace(PE22,RTRIM(Cast(Login_ID as varchar(10))), ''),'%','') PE25
,Replace(Replace(PE28,RTRIM(Cast(Login_ID as varchar(10))), ''),'%','') PE28
,Replace(Replace(PE22,RTRIM(Cast(Login_ID as varchar(10))), ''),'%','') PE29
,(case when len(PE4)-Len(Replace(PE4,RTRIM(Cast(Login_ID as varchar(10))), ''))=0 or [pe4] is null or Replace(PE4,RTRIM(Cast(Login_ID as varchar(10))), '') ='' Then 0 Else 1 End) cntP4
,(case when len(PE9)-Len(Replace(PE9,RTRIM(Cast(Login_ID as varchar(10))), ''))=0 or [pe9] is null or Replace(PE9,RTRIM(Cast(Login_ID as varchar(10))), '') ='' Then 0 Else 1 End) cntP9
,(case when len(PE9)-Len(Replace(PE11,RTRIM(Cast(Login_ID as varchar(10))), ''))=0 or [pe11] is null or Replace(PE11,RTRIM(Cast(Login_ID as varchar(10))), '') ='' Then 0 Else 1 End) cntP11
,(case when len(PE15)-Len(Replace(PE15,RTRIM(Cast(Login_ID as varchar(10))), ''))=0 or [pe15] is null or Replace(PE15,RTRIM(Cast(Login_ID as varchar(10))), '') ='' Then 0 Else 1 End) cntP15
,(case when len(PE17)-Len(Replace(PE17,RTRIM(Cast(Login_ID as varchar(10))), ''))=0 or [pe17] is null or Replace(PE17,RTRIM(Cast(Login_ID as varchar(10))), '') ='' Then 0 Else 1 End) cntP17
,(case when len(PE20)-Len(Replace(PE20,RTRIM(Cast(Login_ID as varchar(10))), ''))=0 or [pe20] is null or Replace(PE20,RTRIM(Cast(Login_ID as varchar(10))), '') ='' Then 0 Else 1 End) cntP20
,(case when len(PE22)-Len(Replace(PE22,RTRIM(Cast(Login_ID as varchar(10))), ''))=0 or [pe22] is null or Replace(PE22,RTRIM(Cast(Login_ID as varchar(10))), '') ='' Then 0 Else 1 End) cntP22
,(case when len(PE25)-Len(Replace(PE25,RTRIM(Cast(Login_ID as varchar(10))), ''))=0 or [pe25] is null or Replace(PE25,RTRIM(Cast(Login_ID as varchar(10))), '') ='' Then 0 Else 1 End) cntP25
,(case when len(PE28)-Len(Replace(PE28,RTRIM(Cast(Login_ID as varchar(10))), ''))=0 or [pe28] is null or Replace(PE28,RTRIM(Cast(Login_ID as varchar(10))), '') =''Then 0 Else 1 End) cntP28
,(case when len(PE29)-Len(Replace(PE29,RTRIM(Cast(Login_ID as varchar(10))), ''))=0 or [pe29] is null or Replace(PE29,RTRIM(Cast(Login_ID as varchar(10))), '') =''Then 0 Else 1 End) cntP29
from mocha

Similar Messages

  • How to change a  value of the field Selection Conditions in Manage- Request

    Hi,
    How to change manualy a value of the field Selection Conditions in Manage infocube -> Requests  ?

    Hi,
    Here is the reason i need to do this:
    The data is loaded by DTP in process chain. Overlaping requests are deleted. But, iIn some cases requests with the same selection options  need not to be deleted. My idea was to change selection options in Manage(infocube) with Abap program without changing selection options in DTP filter,  so that the system would not recognize requests as "overlaping requests".
    So, where is the information about shown in the field Selection Options is stored? In which tables?
    Thanks
    Tigr_Z

  • How do remove commitment value in the PO ? any SAP note avl?

    Hi,
    Project (WBS)releated service PO (Account assignment category P and Item category D), in which SES,GR,IR have been completed for entire Project services for the year 2005,PO history also updatd for SES, GR,IR in the 2005 only.But Now system is showing still commitment value in the PO for the year 2009?.
    Henece how do remove the inconsistency of the  commitment value in the PO for the year 2009?. (i.e value is comming from COOI table entry).Is there any SAP NOTEs are available for this case?
    Note:
    But this case no PR has been refered in the PO. PO has been directly created, and PO  QTY,Value changes have not been done after SES,GR,IR completion.
    But still system  commitment value is showing in the PO for the year 2009, so HOW do remove the value?
    i am looking suitable answers.
    Regards,
    kumar

    Hi,
    Pre-requisites for a commitment update are:                                                                               
    o  In transaction OKKP, the commitment management indicator must be              
           active for the given controlling area in the current fiscal year.                                                                               
    The controlling area is the highest organizational unit in Controlling,              
    however this area is missing from the accounting data of the PO.                                                                               
    o  The accounting objects must be active for commitments:                                                                               
    -  Work orders: The commitment management indicator must be set               
              in transaction KOT2 for the given order type.                                                                               
    -  Cost centers: In transaction KS02, in register "Control", the              
              commitment update indicator must NOT be set.                                                                               
    -  Projects: see note 47992                                                                               
    o  In transaction CUNI, the unit of measurements used at item level              
           must be set to value based commitment.                                                                               
    Please check the following notes 152571, 634298, 459509 and            
    772206 carefully and also 165823. 
    Please check also if the "delivery complete" indicator is set in the PO item (see note 735404).
    Usually for service POs the "Delivery completed" indicator will be   
    hidden and this indicator is fully controlled by the "final entry    
    sheet" indicator in ML81N. You must allow to set this indicator trough a field selection customizing for your PO item.
    Regards,
    Edit

  • How can i get value when the field name is user's defined

    Hi,
    I have a one java method:
    public ResultSet countUserDb(String id) {
    ResultSet rs = null;
    con = dbcon.connect();
    String queryString = ("select count as count from
    db_allocation where user_id='"+id+"'");
    Statement stmt = con.createStatement();
    rs = stmt.executeQuery(queryString);
    When i call it in a jsp file.
    ResultSet counter =db.countUserDb(request.getParameter("id"));
    if(counter.next())
    int x=rs.getInt("count");
    Tomcat said incorrect column name.How can i get the result set when the field name is user's defined.
    Best regards
    Ricky

    You should give the user defined name in the ResultSet.getXXX method to retrieve the column value.
    Example
    SQL:
    Select ename as employeename from emp;
    You should say :
    ResultSet.getString("employeename"); to get the value.
    Alternatively you can retrieve it using column number:
    ResultSet.getString(1);
    Chandar

  • How to remove carraige return from the field while loading external table

    I am facing an issue of not getting rid of carraige returns present in the fileds of the source .csv file while loading the records into external table.
    I had tried using LRTRIM, but it does not help.
    The error I am getting is:
    KUP-04021: field formatting error for field POPULATION_DESCRIPTION
    KUP-04037: terminator not found
    I am pasting one record out of the .csv file which is causing this error as below:
    "Business Card Accounts
    ",123,7 BizCard - Gamers,Control,"Business Card Accounts
    ",75270,75271
    You can see the carraige return in the 1st field as well as 5th field. Filed are separated by commas & eclosed by double quotes.
    Could anybody help on this please?

    Can you copy the file to an external table only version, and then dos2unix it?
    Alternatively, you can use the ACCESS PARAMETERS area in your external table definition to set that your RECORDS DELIMITED BY carriage returns, instead of the default.
    Check out the example here http://www.psoug.org/reference/externaltab.html

  • Meaning of EE in the value in the field ARCKEY of table EDIDC.

    Pls ignore ths thread
    Edited by: Arnab Mondal on Apr 21, 2009 1:14 PM

    Seems no 1 nows the answer. So closing the forum
    Regards,
    Arnab

  • How can we change value of a field in the Repeating Table using SharePoint Workflow 2013.

    Hi
    I have an InfoPath form published on a SharePoint Library. The form contains a Repeating table and after submit a workflow runs. In this workflow I want to change some values of the fields within Repeating table.
    How can I do this?
    Thanks.

    Hi,
    I found a similar thread posted by you here:
    http://social.technet.microsoft.com/Forums/en-US/e1fa36c1-cb5c-456d-ba40-2f26301913d2/how-to-loop-through-each-row-in-a-repeating-table-using-sharepoint-workflows?forum=sharepointgeneralprevious
    I suppose both the threads are reuqesting the method to get values from repeating table via workflow, so we can focus on the issue on the other case. If there is more requestment here, let me know.
    Regards,
    Rebecca Tu
    TechNet Community Support

  • How to replace blank values in DATE field with 00000000

    Hi
    I have a DSO with Date field in which there are blank values. I want to replace the blank values in the DSO for date field with 00000000. Because of this blank values in the DSO the report is giving an ORA error.
    How do we replace the blank values in the DSO for historical data and also the new loads?
    Please advise.
    Thank you.
    Regards,
    Pavan.

    Hi Suman,
    I'm trying to run a query built on a DSO. The DSO has a field 'Start Date'. This Start Date InfoObject has a reference Char as 0DATE.
    This Start Field has blank values due to which I'm getting the ORA-01722 error. I came across many threads with same topic of discussion. As mentioned in one of the Threads I have written a program to update 'Start Date' with 00000000. The code wriiten is "UPDATE /BIC/AZ_MONINV00 SET /BIC/ZSTR_DTE = '00000000' where /BIC/ZSTR_DTE = ' '.
    Now when I see the data in the active data table of DSO the blank value is replaced with '00000000'.
    But If I right click on the DSO click on display data the 'Start Date' field is blank. And now the Query also gets executed without any error. But in the output of the query the 'Start Date' Field has "#" values.
    Can anyone suggest on how to remove these "#" values in the report?

  • How to remove target node if source field value is empty SAP PI Mapping

    Hello,
    how to remove target node if source field value is empty in graphical Mapping.
    Like if
    MIddle name in source filed is empty, I would like to eliminate target field from out put XML.
    Thank you
    John

    Hi Jhon,
    If you want to remove all empty tags and you dont to complicate your message mapping, you can use a XSL, after the message mapping,  to remove all the empty tags:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="node()|@*">
            <xsl:copy>
                <xsl:apply-templates select="node()|@*"/>
            </xsl:copy>
        </xsl:template>
        <xsl:template match="*[not(@*|*|comment()|processing-instruction())
         and normalize-space()='' ]"/>
    </xsl:stylesheet>
    Regards

  • How to check non-numeric value in a field

    Hi all,
    I have a field 'MVALUE'. HOw can I check if I have a non-numeric value in my field. Let us say if I have a value '<25' in this field. How can I check if the value in this field is non-numeric. The field MVALUE is of CHAR datatype.
    Please help. Waiting.........

    Might have to add a space in the string...
    if not mvalue co ' 0123456789'.
    * error
    endif.
    if you allow decimals and commas...
    if not mvalue co ' .,0123456789'.
    * error
    endif.

  • How to 'Only' allow Numeric value in the Edit Box in AcroDialogs

    Hi all,
    I've create an AcroDialog wizard, I need to allow onlu numeric values in the Edit Box. Can someone please help me with this validation?
    Regards,
    Chris

    There isn't a keystroke event for custom JavaScript dialogs, or any proper interactive events for the fields.  You can validate fields when the user presses OK, and you can test fields when the user changes focus by setting the "Action" property for the field.  But the only practical way to restrict user input to numbers is to use George's suggestion.  There is a number property for the fields but it has an undesirable side affect and I never use it.
    Thom Parker
    The source for PDF Scripting Info
    pdfscripting.com
    The Acrobat JavaScript Reference, Use it Early and Often
    http://www.adobe.com/devnet/acrobat/javascript.html
    Then most important JavaScript Development tool in Acrobat
    The Console Window (Video tutorial)
    The Console Window(article)

  • How to enter values in the fields of standard SAP Infotype e.g. IT0024

    Hi,
    How to enter values in the fields of standard SAP Infotype?
    e.g. I want to enter values in infotype IT0024(Qualifications) in the field AUSPR(Profincy):-
    1-Level 1
    2-Level 2
    3-Level 3
    4-Level 4
    5-Level 5
    Thanks,
    Ameet

    Hi Divya,
    I checked with the screen and report which is mentioned by you. But I want to modify/make changes that should appear in the screen when you view details for a particualar employee in Qualifications(IT0024).
    Please refer the screen 2000 of module pool MP002400 in SE80. In that screen I want to make change as listbox with key.
    Can it be achieved in the same way as mentioned by you before by making standard SAP report as Z and then modify using layout editor?
    Please help me out. I think I am almost there.
    Thanks,
    Ameet

  • How to get the value of the field 'KOMP-NETWR' in Pur.

    Hello everyone,
    how do i get the value of the field 'KOMP-NETWR' in the purchase order.
    thanks
    Arnaud

    Hi,
    Try this code similarly for komp
    REFRESH i_komv.
    CLEAR i_komv.
    CALL FUNCTION 'PRICING_REFRESH_TX'.
    CALL FUNCTION 'REFRESH_TAX_TABLES'
    EXPORTING
      LIVERY        =
    LOOP AT i_ekpo INTO wa_ekpo.
      wa_taxcom-bukrs = wa_ekko-bukrs.
      wa_taxcom-budat = wa_ekko-bedat.
      wa_taxcom-bldat = wa_ekko-bedat.
      wa_taxcom-waers = wa_ekko-waers.
      wa_taxcom-hwaer = wa_ekko-waers.
      wa_taxcom-kposn = wa_ekpo-ebelp.
      wa_taxcom-mwskz = wa_ekpo-mwskz.
      wa_taxcom-wrbtr = wa_ekpo-netwr.
      wa_taxcom-xmwst = 'X'.
      wa_taxcom-lifnr = wa_ekko-lifnr.
      wa_taxcom-ekorg = wa_ekko-ekorg.
      wa_taxcom-matnr = wa_ekpo-matnr.
      wa_taxcom-werks = wa_ekpo-werks.
      wa_taxcom-matkl = wa_ekpo-matkl.
      wa_taxcom-meins = wa_ekpo-meins.
      wa_taxcom-mglme = wa_ekpo-menge.
      wa_taxcom-mtart = wa_ekpo-mtart.
      wa_taxcom-land1 = wa_ekko-lands.
      wa_taxcom-ebeln = wa_ekpo-ebeln.
      wa_taxcom-ebelp = wa_ekpo-ebelp.
      CALL FUNCTION 'CALCULATE_TAX_ITEM'
        EXPORTING
          i_taxcom                  = wa_taxcom
        IMPORTING
          e_taxcom                  = wa_taxcom
        TABLES
          t_xkomv                   = i_komv
        EXCEPTIONS
         mwskz_not_defined         = 1
         mwskz_not_found           = 2
         mwskz_not_valid           = 3
         steuerbetrag_falsch       = 4
         country_not_found         = 5
         OTHERS                    = 6
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    clear wa_taxcom.
    ENDLOOP.
    LOOP AT i_komv INTO wa_komv.
      CASE wa_komv-kschl.
    *EXCISE DUTY
        WHEN 'JMOP'.
          v_jmop = v_jmop + wa_komv-kwert.
    endcase.
    endloop.
    Hope this might be of some use.
    Regards,
    sirisha

  • How to put the SQL-statement returned value into the field (as a default)

    Hi,
    I am using Developer/2000 (Forms Designer) under windows 98.
    Please tell me how to put the SQL-statement value (as a default value) into the field before enter-query mode. Noted that I have tried the following ways but still some problems:-
    1) Place the SQL-statement into PRE_QUERY trigger in the form/block level.
    There is a message box which ask 'Do you want to save the changes?'.
    2) Place the SQL-statement before execute enter_query. There is still a
    message box which ask 'Do you want to save the changes?'.
    Any hints? Thanks. Urgent.

    solved it!
    1) Suppress DEFAULT save message
    if form_failure then
    raise form_trigger_failure;
    end if;
    2) Place the default value before enter-query.
    Ref: Title='Default value in query field in ENTER_QUERY mode' in designer forum by CVZ
    form level trigger
    ============
    WHEN-NEW-ITEM-INSTANCE
    =======================
    if :system.mode = 'ENTER-QUERY' then
    :block.item := 'default waarde';
    end if;
    3) Suppress the changes whenever leaving the default field.
    if :block.item is null then
    -- assign statement
    end if;

  • How to set the default values of the field of the context.

    Hi Experts ,
    I want to set the default value of the field of the context.
    Where and how this declaration should be done.
    Thanks in Advance.

    In the context tab of the view. Select the attribute for which you want to set the default value.it will show the properties at the bottom. set the Default value property to the value which you want to set as the default value.
    Regards
    Naresh

Maybe you are looking for

  • Pinnacle Studio MovieBox Plus: FireWire to USB!

    I don't have a Mac, but I've used them at my school, and I plan to get a Mac in the near future. Initially I figured I'd buy the $999 white MacBook since I use a Canon ZR800 MiniDV camcorder, until I just remembered I have THIS: http://www.apartmentt

  • HT5958 This new closed Library system stinks. Now you can't access media from other programs. Any work around?

    Let me start by saying I have been using FCP X for a year now and really love it.  We produce a half hour weekly TV series so I put it through its paces on a weekly bases. I was horrified to return from the holidays to find out that an automatic upda

  • Outgoing payment problem

    Hi Gurus, Can somebody help on below issue: we have scenario payment with using payment on behalf, so one company paid for other company code. and the problem company code in different country. Example: Company A (country SG, LC=SGD) , paid on behalf

  • MRP contoller From Remote in PR

    Hi, I got a situation where I'm having STR created in remote with MRP contoller lets say 003 and in base MRP controller is maintained as 001. But when by o3o_sc01 I'm converting the STR to STO & PR, the PR is capturing the STR MRP contoller 003 not 0

  • Multiple calendar entry replicates

    Whenever I try to use iCloud, many of my calendar entries, especially older ones, are replicated, and may be replicated multiple times. For instance, one repeated calendar entry is replicated about 20-25 times on each and every every day. Interesting