Trim up to a certain character

hi everyone, i hope someone can help me with this.
i have a string that I need to trim up to a pipe character ("|"). the problem is, the length of the characters before this pipe character varies greatly. How can I trim the string (for example, abcdef346 | rfgt...) and get only abcdef346 as the result?
any help would be greatly appreciated.

Try this
Code Snippet
SELECT
LEFT(column_name,(charindex('|',coulmn_name)-1))
as columnname
FROM table_name
 Thanks Magnal 
 Your query helped me too.
Just a word of caution that it will break if there are values without | character at all
so a much safer approach would be this
SELECT LTRIM(RTRIM(LEFT(column_name,charindex('|',coulmn_name + '|')-1))) as columnname
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • Detect a certain character and return it's index in the string

    what's the function that detects a certain character e.g."X" in a string line and returns its index then continues to detect the next 'X" in the same line. do i also need to store them in an array?

    You have to write one. Also, please stop starting new threads on this topic. This is all related to the same problem you're having, and posting so many threads makes it tough on everyone who wants to help you. It's rude, and wasteful of other people's time; namely, the folks that are actually trying to help you solve your problem.

  • How to change a certain character in a string?

    hi,
    how can i change a certain character in a string. Lets say i have a string s="0000" and i want to change the last character (s.charAt(3)) to be a 1. how would i go about doing so?

    i did this
    num.charAt(lspace) = s.charAt(i+1);and am getting an errorThat's because you can't do that. You should go for one of the alternatives mentioned above.
    Kaj

  • How do i call recieve function automatically on certain character believe on terminal

    i think i m using intalcomback function but function is not calling on recieving certain character. i simply want to get data continuously and disply the whole packet and then want to seperate ceratain data from that.

    Hi khadimhussain,
    There is very little useful information here.  Could you please provide a detailed description of your application (with context: I need to know why you are doing what you are doing not just what you are doing) and what you want to accomplish with the installComCallback function as well as either screenshots or an actual copy of your code? It will be very difficult to debug your code without being able to see how you are implementing it.  

  • How do i call recieve function automatically on when certain character receive on terminal

    i m using
    installComCallback
    function but function is not calling on recieving certain character. i simply want to get data continuously and disply the whole packet and then want to seperate ceratain data from that. i use the event character and i selected the character CR. i m sending 29 bytes packet from labwindows application and reciveing this packet and i used installcomcallback function and used evencharacter. but the function is not recieving
     

    Hi khadimhussain,
    There is very little useful information here.  Could you please provide a detailed description of your application (with context: I need to know why you are doing what you are doing not just what you are doing) and what you want to accomplish with the installComCallback function as well as either screenshots or an actual copy of your code? It will be very difficult to debug your code without being able to see how you are implementing it.  

  • Sending PDF with a certain character type

    Hi all,
    1. After getting the print parameters with the function u2018GET_PRINT_PARAMETERS'
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING
    DESTINATION = 'N006'
    *LINE_SIZE = 080
    line_count     = 65
    IMMEDIATELY = ' '
    NO_DIALOG = 'X'
    IMPORTING
    OUT_PARAMETERS = PARAMS
    VALID = VALID.
    2. NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG NO-TITLE NO-HEADING.
    3. Make a PDF for a certain spool with the function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    4. And at last sending the pdf with  thefunction SO_DOCUMENT_SEND_API1'
    The users receive wel the pdf, but they want another character type (bigger one) , how can I build this ?
    Thanks

    No solution

  • Certain character string in RSS truncates the feed

    Safari 3.1.2 - When the string "%&#$@" shows up in an RSS feed (presumably random - it was used in place of profanity), the RSS feed is truncated after the "%", so the rest of that article and all subsequent articles are not displayed. Bug? Or, are such character sequences supposed to be properly escaped or encoded somehow by the feed generator?
    feed in question:
    feed://syndication.thedailywtf.com/TheDailyWtf
    link to the article, in case it has expired out of the RSS feed:
    http://thedailywtf.com/Articles/The-Greatest-Idea-Contest.aspx

    Hi,
    The value that is written to the new record is the "r" (=return) value not the "d" (=display) value, so you should check the definition of the field on the new record to make sure that it is large enough to accept the CD_ORDEM_SERVICO value. If it is, you should then do a View Source on the page, locate the option tags and check the value attributes to make sure that they are being rendered correctly.
    Andy

  • How to remove certain character from a string?

    Follows the table:
    CT_TRABALH
    400rj101
    400rj102
    400rj103
    400rj104
    400rj105
    400rj106
    400rj107
    400rj108
    400rj109
    400rj1010
    400rj1011
    I woulld like to make the following with its values. For example the value 400rj1010
    I would like to remove its last character (400rj101) and then relace the last zero for the last number(400rj111) by query. Is there any way I can achieve this?

    I would write something a little more generic :
    SCOTT@demo102> with tbl as
      2      (select '400rj101' as CT_TRABALH from dual union all
      3       select '400rj102' from dual union all
      4       select '400rj103' from dual union all
      5       select '400rj104' from dual union all
      6       select '400rj105' from dual union all
      7       select '400rj106' from dual union all
      8       select '400rj107' from dual union all
      9       select '400rj108' from dual union all
    10       select '400rj109' from dual union all
    11       select '400rj1010' from dual union all
    12       select '400rj10120' from dual union all
    13       select '400rj14120' from dual union all
    14       select '412rj14120' from dual union all
    15       select '400rj1011' from dual )
    16  select CT_TRABALH,
    17         case when substr(CT_TRABALH,-1,1) = '0'
    18              then  decode(instr(substr(CT_TRABALH,1,length(CT_TRABALH)-1),0,-1),
    19                           0, substr(CT_TRABALH,1,length(CT_TRABALH)-1),
    20                              substr(CT_TRABALH,1,instr(substr(CT_TRABALH,1,length(CT_TRABALH)-1),0,-1)-1)
    21                              ||substr(CT_TRABALH,-2,1)
    22                              ||substr(CT_TRABALH,instr(substr(CT_TRABALH,1,length(CT_TRABALH)-1),0,-1)+1,
    23                               length(CT_TRABALH)-instr(substr(CT_TRABALH,1,length(CT_TRABALH)-1),0,-1)-1))
    24              else CT_TRABALH
    25              end as CT_TRABALH_0
    26  from tbl;
    CT_TRABALH CT_TRABALH_0
    400rj101   400rj101
    400rj102   400rj102
    400rj103   400rj103
    400rj104   400rj104
    400rj105   400rj105
    400rj106   400rj106
    400rj107   400rj107
    400rj108   400rj108
    400rj109   400rj109
    400rj1010  400rj111
    400rj10120 400rj1212
    400rj14120 402rj1412
    412rj14120 412rj1412
    400rj1011  400rj1011
    14 rows selected.
    SCOTT@demo102> Nicolas.

  • Bringing back results that match a certain character type

    Hi, thank you for any help.
    Below is a few values from a field in a database table. I like to bring back the values that only have ###-####. I do not want to bring back any other values that has any other kind of characters in them unless its a number. Thank you
    I want to bring back only         
    105-1110          
    105-1114          
    105-1121          
    105-1125          
    105-1298          
    105-1300  
    I dont want to bring back the ones below.
    001-10            
    001-2-13          
    002-2-10          
    003-43            
    003-52            
    003-87           
    0820-FR           
    1-0-17            
    1-0-18            
    1-0-19            
    1-0-20            
    1-0-22            
    1-0-29            
    1000-SW           
    1030-SW                 
    105-CIFM          
    Edwin Lopera

    One option
    declare @table table(val varchar(10));
    insert into @table
    values
    ('105-1110'),
    ('105-1114'),
    ('105-1121'),
    ('105-1125'),
    ('105-1298'),
    ('105-1300'),
    ('001-10'),
    ('001-2-13'),
    ('002-2-10'),
    ('003-43'),
    ('003-52'),
    ('003-87'),
    ('0820-FR'),
    ('1-0-17'),
    ('1-0-18'),
    ('1-0-19'),
    ('1-0-20'),
    ('1-0-22'),
    ('1-0-29'),
    ('1000-SW'),
    ('1030-SW'),
    ('105-CIFM')
    select * from @table
    where val like '[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • How to use character styles in the Find/Change JavaScripts?

    First, good luck to Ole. He's been so helpful (and such a good writer, too). All the best!
    My Find/Change JavaScripts are running into trouble at line 159 of the ExtendScript Toolkit. The script is searching for a particular font, to which it should then apply a character style. I'm using the format I see in Adobe's "FindChangeList" sample text, but the script is still hitting a wall. What am I doing wrong? I'd like to have a working method for searching, not only for fonts, but also for finding a particular character or paragraph style and then applying a new style.
    Simple stuff, but I'm roadblocked.
    Here is the script so far:
    //This script applies the DFKai character style to the Arial Unicode font.
    text {findWhat:"", appliedFont:"Arial Unicode MS", fontStyle:"Regular"} {appliedCharacterStyle:"DFKai"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find Unicode font; change to DFKai character style.
    Thanks for your help!
    Gary Niemeier

    You are absolutely correct. I don't know how those spaces got there! I copied the text from the "FindChangeList.txt" document, but somewhere along the way, a software program "helpfully" added the spaces. (Rest assured, it wasn't copied from AppleScript. I stick with JavaScript.) Anyway, the script now runs like a charm.
    My thanks to you! Another "newbie" mistake easily spotted, eh?
    One thing, though, if Adobe is reading this: please flesh out the "FindChangeList.txt" file for those who are not programmers/scripters. I'm just a normal InDesign user, and I really need examples of basic syntax in order to use the "Find/Change" script correctly. I'm referring to the syntax involved with finding or changing text with a certain character or paragraph style. I often search for styles, and those properties should be provided in the help file. A couple of samples are all that's needed. (I did read through the JavaScript reference guide provided by Adobe, and even in the "Find/Change" section, it did not provide this information!). Furthermore, I often search text for a specific font. Why isn't this syntax included as well? It would easy to do and would save users a lot of fumbling around.
    Thanks again, all the best.

  • Myterious character in text file! Please help!

    Hello all
    I am experiencing a problem identifying a certain character in a text file I have to import.
    In the .txt doc the char appears as a square, and when copying the text to MSWord, it seems like a paragraph sign.
    But when I'm searching for paragraph signs or line breaks, it is skipping that char, so it must be something else.
    Question:
    How will I find out what char it is, in order to remove it with StringTokenizer?
    I already tried ("\r") and ("\n")
    Any ideas will be welcome
    Regards
    Jaco

    Get the bytes using String.getByes(), print out the value of the byte for the particular character u are looking ,and then u will know which ASCII char it is.
    Most likely it would be char(13).
    byte [] bytes=s.getBytes();
    for(int i=0;i<bytes.length;i++)
    system.out.println(byte);
    Hope it helps.

  • Removing characters from string after a certain point

    Im very new to java programming, so if this is a realy stupid question, please forgive me
    I want to remove all the characters in my string that are after a certain character, such as a backslash. eg: if i have string called "myString" and it contains this:
    109072\We Are The Champions\GEMINI
    205305\We Are The Champions\Queen
    4416\We Are The Champions\A Knight's Tale
    a00022723\We Are The Champions\GREEN DAYi would like to remove all the characters after the first slash (109072*\*We...) leaving the string as "109072"
    the main problem is that the number of characters before and after is not the always the same, and there is often letters in the string i want, so it cant be separated by removing all letters and leaving the numbers
    Is there any way that this can be done?
    Thanks in advance for all help.

    You must learn to use the Javadoc for the standard classes. You can download it or reference it on line. For example [http://java.sun.com/javase/6/docs/api/java/lang/String.html|http://java.sun.com/javase/6/docs/api/java/lang/String.html].

  • Multi character set support

    we plan to implement Interconnect to get new customer records created in many databases (at distributed locations) to be populated into a central system.
    all the databases are running on Oracle Database 9.x and we plan to use DB adapters to access each of them.
    3 of these databases store data in double-byte format (Traditional Chinese, Simplified Chinese, Japanese). others are in standard US/American English
    my questions are:-
    1) does my central system's database have to be set to use a certain character set too ?
    2) do i have to configure Interconnect to ensure that data from non-English systems are retrieved and populated correctly into my central database
    thanks for any response

    Hi,
    We are also facing similar problem. We are using IC version 9.0.2. We have AQ adapter at source and DB adapter at destination. The characterset at DB application database is UTF-8. Where as in AQ application database is AR8MSWIN1256. We are using request/reply scenario. But the reply message which gets enqueued to the queue by AQ adapter contains '??????' (arabic data)
    We have specified the encoding type in both adapter.ini files but no use.
    We also followed the steps as stated in Metalink bug id 2375248. But nothing works. Can somebody help us???
    -Vimala

  • Selecting with a special character

    Hi,
    I have a table in which an user can query via a sql prompt (accept) for a text he wants to search for. This search string can contain special characters like @,$,& etc but nog on a specific position. Sometimes they search for bbbb.hhhh_23, the next time the search for pppp & xxxx. I already thought that (double) quoting would help, tried escaping (\) also but still got errors with my procedure. So, how can I search those tables with the special chars and display the text the user is searching for?
    Thanks!
    Paul

    Hi,
    Please see the forum FAQ {message:id=9360002}
    What exactly is the problem you're having?
    What input are you giving, and what output are you expecting? Remember, you need to post something that the poeple who want to help you can run to re-create the problem and test their ideas. In this case, you need to post something like this:
    "I'm running this in schema ATL5_TEST, which includes this table: CREATE TABLE TABLE_X ... with these rows: INSERT INTO table_x ....
    When I run the script and set &search to 'A_B', I'm expecting these results ... because ... but instead, I'm getting these results ... As you can see, the results are missing ....
    When I run the script and set &search to 'C%D', I'm expecting ... because ... but instead, I get this error message: ..."
    Simplify the script as much as possible. For example, if the problem involves how to accept a certain character into a substitution variable, then you don't need to post 60 lines of PL/SQL code, even if your goal is to use that substitution vaiable in that PL/SQL code. Just post the ACCEPT statement, maybe a very simple "SELECT ... FROM dual;" query to get some results, a couple of inputs, and the expected outputs/
    Never write, let alone post, unformatted code. Indent the code to show the scope of BEGIN, IF, LOOP, and so on.
    When posting any formatted text (including, but not limited to, code) on this site, type these 6 characters:
    \(all small letters, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    The EXCEPTION section you're using is only hiding details about the error.  Get rid of it.
    Whenever you write dynamic SQL, start by displaying the SQL string *instead of* executing it.  for exampledbms_output.put_line (v_sql || ' = v_sql before EXECUTE IMMEDIATE');
    -- execute immediate v_sql
    -- into v_match_count;
    When you get this much running, and the output is what you expect, then you can uncomment the EXECUTE IMMEDIATE statement.  Later, you'll want to comment out the call to put_line.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to read/display a sentence after or before a specific character?

    Hi
    I am trying to show a users firstName after the 1st charter
    i.e. the name is Kevin
    I only want to show EVIN not k, how would I do that?
    Can I use charAt??
    and what if I want to show a users firstName before a certain character
    i.e. the name is Kevin I only want to show KEV and not IN

    Thank You!
    Yes, it is working fine now :D
    *Chapter 2, challenge 4
    *Write an application that reads in a user?s sentence of unknown, possibly
    *mixed upper- and lowercase letters, capitalizes the first letter of the sentence,
    *makes all other letters lowercase, and makes sure there is a period
    *at the end.
    import java.io.*;
    public class c2c4 {
    public static void main(String args[]) {
    String name="";
    String firstName = "";
    BufferedReader reader;
    reader = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("\n What is your first name? ");
    try {
         firstName= reader.readLine();
         name= firstName.substring(1);
         catch (IOException ioe) {
         System.out.println("IO Exception Occurred");
         System.out.println("So your firstname is: " + firstName.toUpperCase().charAt(0) + name.toLowerCase() +".");
    }I removed the comment and made the String name *= ""*;
    and it worked fine :)
    Now, I got one more question to ask though and this isn't really related to any of the questions that I am doing yet...
    What if I really wanted to Uppercase and LowerCase all the characters alternatively...
    I mean like:
    sentence is:
    One two Three four
    Now the output I want it to be is like: oNe TwO tHrEe FoUr
    ---Sorry, I am really keen to learn thats why asking many questions!
    Edited by: kevingupta.2271990 on Aug 15, 2010 10:05 PM

Maybe you are looking for