Get data from string

My Table Column have below data
COLUMN A
Name of my Country is India
I am from Country Japan
My Country is China
How to get result as below
"Country is India"
"Country Japan"
"Country is China"
ShanmugaRaj

Try:
DECLARE @t TABLE (Info VARCHAR(300));
INSERT INTO @t (Info)
VALUES ('Name of my Country is India')
,('I am from Country Japan')
,('My Country is China')
,('Testing');
SELECT Info
,substring(Info, NULLIF(charindex('Country', Info), 0), LEN(Info)) AS [Country Info]
FROM @t;
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles

Similar Messages

  • Get date from Oracle when local time zone is different from Oracle time zon

    Hi!
    Local machine time zone= +2
    Oracle time zone= +1
    I set date to Oracle using java.sql.Date.
    From application I save date at 00:30 clock and send e.g. 28.06.2002, but in Oracle date is save as 27.06.2002 01:00 (hour=01 , I suppose that is because java.sql.Date hasn't time the Oracle set it time = time zone=+1) And when I get date from Oracle I get incorrect date. In SQL I don't use date masks. Maybe solution is to use java.sql.Timestamp object (when save date to Oracle) instead of java.sql.Date?
    But if I save date at e.g. 01:00 clock and send e.g. 28:06.2002 in Oracle, date is save as 28.06.2002 01:00 and when I read from Oracle I get correct date.
    Thank you.

    Hi!
    Local machine time zone= +2
    Oracle time zone= +1
    I set date to Oracle using java.sql.Date.
    From application I save date at 00:30 clock and send
    e.g. 28.06.2002, but in Oracle date is save as
    27.06.2002 01:00 (hour=01 , I suppose that is because
    java.sql.Date hasn't time the Oracle set it time =
    time zone=+1) Presumably you are using setTimestamp() to store the value. If you are explicitly using a varchar (string) then you will have to correct the timezone your self.
    And when I get date from Oracle I get
    incorrect date. In SQL I don't use date masks. Maybe
    solution is to use java.sql.Timestamp object (when
    save date to Oracle) instead of java.sql.Date?The method setDate/getDate store a 'date' which is not the same as a 'date and time' for which setTimestamp/getTimestamp are used.
    But if I save date at e.g. 01:00 clock and send e.g.
    28:06.2002 in Oracle, date is save as 28.06.2002
    01:00 and when I read from Oracle I get correct date.
    Thank you.

  • How to get data from subsites list of SharePoint 2010 in ssrs

    Hi,
    Can someone help me on this issue.
    I want to create a report using ssrs, I have some of the data in SQL and some of the data in sharepoint list.
    First I need to go to SQL and get the data from the table which contains URL for the subsite in sharepoint.
    after that I need to go to all the subsites and go to perticulat list in the subsites and get data from that list.
    for example, their is a top level site "abc"
    it contains sub site "123", "456","567", etc.. All this sub sites contain a list by name "Sample List", Now I need to go to that sub site list(Sample List) and get list-item column say "created By" which
    is created on particular date. 
    in my report, I need to print the sub site "url/Title" which comes from SQL database and list-item column  "Created By" of that sub site list "Sample List".
    I tried using subreport inside a report by using "Microsoft SharePoint List" as a datasource, but when it comes to real time we don't know how many subsites will be created, so we can't create a datasource for each subsite site.
    I guess we need to be using XML as a datasource, but how can we go to particular subsite in query while using XML, since all subsites have list with the same name ?
    I appreciate your help.
    Thank you,
    Kishore 

    Hi Kishore,
    SQL Server Reporting Services(SSRS) supports expression-based connection strings. This will help us to achieve the goal you mentioned in this case:
    Create a new report
    Create a Data Source in the report with the connection string like this:
    http://server/_vti_bin/lists.asmx (We use static connection string instead of expression-based connection string now, as it is not supported to get fields based on expression-based connection string in design time. We will change it to be expression-based
    connection string later)
    Create the data set(as you have done using XML query language). Please use list name instead of GUID in the listName parameter.
    Design the report(e.g. Add controls to the report)
    Now, let's change the connection string to be expression-based. First, please add a parameter to the report, move this parameter to top. This parameter is used to store the sub site name.
    Open the Data Source editor, set the connection string to be: ="http://server/" & Parameters!parameterCreatedInStep5.value & "_vti_bin/lists.asmx"
    In the main report, pass the sub site name to the report we created above via the parameter created in step5
    That is all.
    Anyway, this is actually a SQL Server Reporting Service(SSRS) question. You can get better support on this question from:
    http://social.technet.microsoft.com/Forums/en/sqlreportingservices/threads
    For more information about Expression-Based connection string, please see:
    http://msdn.microsoft.com/en-us/library/ms156450.aspx#Expressions
    If there is anything unclear, please feel free to ask.
    Thanks,
    Jinchun Chen
    Jin Chen - MSFT

  • Cant get data from text file to print into Jtable

    Instead of doing JDBC i am using text file as database. I cant get data from text file to print into JTable when i click find button. Goal is to find a record and print that record only, but for now i am trying to print all the records. Once i get that i will change my code to search desired record and print it. when i click the find button nothing happens. Can you please take a look at my code, dbTest() method. thanks.
    void dbTest() {
    DataInputStream dis = null;
    String dbRecord = null;
    String hold;
    try {
    File f = new File("customer.txt");
    FileInputStream fis = new FileInputStream(f);
    BufferedInputStream bis = new BufferedInputStream(fis);
    dis = new DataInputStream(bis);
    Vector dataVector = new Vector();
    Vector headVector = new Vector(2);
    Vector row = new Vector();
    // read the record of the text database
    while ( (dbRecord = dis.readLine()) != null) {
    StringTokenizer st = new StringTokenizer(dbRecord, ",");
    while (st.hasMoreTokens()) {
    row.addElement(st.nextToken());
    System.out.println("Inside nested loop: " + row);
    System.out.println("inside loop: " + row);
    dataVector.addElement(row);
    System.out.println("outside loop: " + row);
    headVector.addElement("Title");
    headVector.addElement("Type");
    dataTable = new JTable(dataVector, headVector);
    dataTableScrollPane.setViewportView(dataTable);
    } catch (IOException e) {
    // catch io errors from FileInputStream or readLine()
    System.out.println("Uh oh, got an IOException error!" + e.getMessage());
    } finally {
    // if the file opened okay, make sure we close it
    if (dis != null) {
    try {
    dis.close();
    } catch (IOException ioe) {
    } // end if
    } // end finally
    } // end dbTest

    Here's a thread that loads a text file into a JTable:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=315172
    And my reply in this thread shows how you can use a text file as a simple database:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=342380

  • How to get data from a table in a condition between twomonth

    hai friends
    I have a query that is i want to get data from a table based on a condition between two months in a format of char column
    Ex
    I have a column called from_month in the format of 'mon/yyyy'(already converted from date')
    then the second column is to_month in the same format 'mon/yyyy'
    now i wiil select from_month and to_month like
    from month jan/2009
    to month mar/2010
    how to use between of two months in the format of char.Please tell me how to get two different month between data.

    Hi,
    This may be of help.
    Remember Pointless has made a point ;) (worth millions)
    If possible , DO NOT store dates as strings or numbers.Let dates be dates.
    WITH dat AS
    (SELECT ' THIS IS JAN' x,to_char(to_date('01-JAN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS FEB' x,to_char(to_date('01-FEB-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS MAR' x,to_char(to_date('01-MAR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS APR' x,to_char(to_date('01-APR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS MAY' x,to_char(to_date('01-MAY-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS JUN' x,to_char(to_date('01-JUN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS JUL' x,to_char(to_date('01-JUL-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS AUG' x,to_char(to_date('01-AUG-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS SEP' x,to_char(to_date('01-SEP-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS OCT' x,to_char(to_date('01-OCT-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS NOV' x,to_char(to_date('01-NOV-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual)
    SELECT * FROM dat
    WHERE to_date(y,'mon/yyyy') BETWEEN to_date('01 jan 2009','dd mon yyyy') AND to_date('01 mar 2009','dd mon yyyy')Cheers!!!
    Bhushan

  • How to get data from a file?

    Hello everyone, i'm new to this forum and to java too. Ok, so here is what i want to do:
    I want to get data from a file containing words and numbers and store them into variables that i will use them after to insert into a database table. For example i have a file called employees.txt in this form:
    eid ename zipcode Hire_date
    1000 "Jones" 67226 "12-DEC-95"
    In C++ i declare variables for each data and store them, for example in this case:
    ifstream in("somefile");
    string name, hdate;
    int eid, zip;
    in >> eid >> ename >> zip >> hdate;
    So i want to do the same thing in JAVA but i can't make it work. So, i would appreciate if someone could give me a simple example how to do it. Thank you.

    [http://java.sun.com/docs/books/tutorial/essential/io/index.html]

  • Best way To get data from another application using NDDE lbrary

    My vb.net application gets data from another application using NDDE Library. I got stocks prices (open,high,low,close,volume,change......(about 15 records for each stock)) (about 200 stocks) . I don't know if there is a problem in my code.
    This is my code:
    l : is the list of stocks.
    This Sub connects to server and requests the data :
    Public Shared Sub GetQuotes()
    Try
    client1 = New DdeClient(server, topic)
    client1.Connect()
    For i As Integer = 0 To l.Count - 1
    client1.StartAdvise("QO." & l(i).t & ".TAD$last", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$open", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$high", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$low", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$pclose", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$volume", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$date", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$time", 1, True, 60000)
    Next
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try
    End Sub
    and then I get the data from Client_advise sub (called each time a value changed )and fill the list. What I know is that client advise gets only one record for single stock each time is called..
    Example: for stock AAPL. 1st time enters client_Advise I get open price for AAPL, 2nd time I get high price for AAPL,3rd time I get low price..... and I update the value in the List (l)
    This the client_Advise Sub:
    Private Shared Sub client1_Advise(ByVal sender As Object, ByVal e As NDde.Client.DdeAdviseEventArgs) Handles client1.Advise
    For q As Integer = 0 To l.Count - 1
    If l(q).t = w(1) Then
    Dim item() As String = e.Item.Split("$")
    If l(q).Open = "#" Then
    l(q).Open = "0"
    End If
    If l(q).hi = "#" Then
    l(q).hi = "0"
    End If
    If l(q).lo = "#" Then
    l(q).lo = "0"
    End If
    If l(q).Close = "" Or l(q).Close = "#" Then
    l(q).Close = "0"
    End If
    If l(q).pclose = "#" Then
    l(q).pclose = "0"
    End If
    If item(1) = "open" Then
    l(q).Open = Format(Val(e.Text), "0.00")
    ElseIf item(1) = "last" Then
    l(q).Close = Format(Val(e.Text), "0.00")
    ElseIf item(1) = "high" Then
    l(q).hi = Format(Val(e.Text), "0.00")
    ElseIf item(1) = "volume" Then
    l(q).Volume = Val(e.Text)
    ElseIf item(1) = "low" Then
    l(q).lo = Format(Val(e.Text), "0.00")
    ElseIf item(1) = "pclose" Then
    l(q).pclose = Format(Val(e.Text), "0.00")
    If l(q).pclose <> "" And l(q).pclose <> "#" And l(q).Close <> "" And l(q).Close <> "#" Then
    l(q).c = Format(l(q).Close - l(q).pclose, "0.00")
    l(q).cp = Format(((l(q).Close - l(q).pclose) / l(q).pclose) * 100, "0.00")
    End If
    l(q).flag1 = 2
    ElseIf item(1) = "date" Then
    l(q).Date1 = e.Text
    ElseIf item(1) = "time" Then
    l(q).Time = e.Text
    End If
    Exit For
    End If
    Next
    End Sub
    Am I doing something wrong which inreases CPU usage to 80 or 90 % ?
    Thanks in advance.

    Hi MikeHammadi,
    According to your description, you'd like to get data from another app using NDDE library.
    When using the NDDE library, the CPU usage is high. As the NDDE library is third-party library, it is not supported here. I suggest you checking if the problem is caused by the NDDE library.
    If you'd like to get data from another app. I suggest you could save the data in the dataBase, and then read it in another application if necessary.
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get data from hierachy lookup table

    there is a hierachy lookup table A, and I want to get data from A.
    but the following code does work properly:
    WebTreeNode result = catalog..GetHierarchy(tableName,nodeID);
    could anybody give some suggestion or solution of getting data from hierachy lookup table,
    3x

    Hi fei,
    Please look at the following code.
    I hope it will give you some clues...
    private void showHierarchy() throws StringException
        ResultSetDefinition rsd = new ResultSetDefinition(<code name of your hierarchy table>);
        rsd.GetFields().Add(<code name of a field in your hierarchy table>);
        Search search = new Search(<code name of your main table>);
        WebTreeNode treeNode = catalogData.GetResultTree(search, rsd, 0);
        printHierNameRecursive(treeNode, 0);
    private void printHierNameRecursive(WebTreeNode root, int level) throws StringException
        WebTreeNodeArray arr = root.GetChildren();
        for (int i = 0; i < arr.GetSize(); i++)
            for (int tab = 0; tab < level; tab++)
            System.out.print("t");
            String catName = arr.GetWebTreeNodeAt(i).GetValueAt(<code name of a field in your hierarchy table>).GetStringValue();
            System.out.println(catName);
            printHierNameRecursive(arr.GetWebTreeNodeAt(i), level + 1);
    Regards,
    Nir

  • How to get data from php to java via xmlrpc

    I have been trying to get data from php through apache xmlrpc to java.
    I do get an value as result. The result is "Array". How how do i convert the XMLRPC Object "Array" to Java Object?
    Inside the XMLRPC "Array" Object there is object too of type Array from php.
    See code for java here
    Object result = client.execute( "blogger.getCategories", params1 );
    Code from php here
    function getCategories($appkey, $username, $password)
         global $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue;
         $structArray = array();
         $structArray[] = new xmlrpcval(array("one" => "test"));
         return new xmlrpcresp(new xmlrpcval( $structArray , $xmlrpcArray));     
    I do get Standard String and Integer from php to Java through XMLRPC.
    Can someone help me.
    Edited by: Electron32 on Aug 13, 2010 9:44 AM

    That is what is so strange. I return an 'array' through xmlrpcval() and in Java I tried to cast it to ArrayList, Vector,String[] but get an error
    Object[] result = (Object[]) client.execute( "blogger.getCategories", params1 );
    String[] array = (String[]) result;
    Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
            at com.dirdalit.window.Main.main(Main.java:41)
    Edited by: Electron32 on Aug 13, 2010 12:25 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Too big switch - get data from array

    I have text file (CSV). Parse file and set data to array, e.g. ArrayList. Get data from array and initialize object MyDoc (by setXXX methods)
         for (int index = 0; index < list.size(); index++) {
                   currentElement = list.get(index);
                   switch (index) {
                   case 0:
                        myDoc.setField1(currentElement);
                        break;
                   case 1:
                        myDoc.setField2(currentElement);
                        break;
                   case 70:
                        myDoc.setField70(currentElement);
                        break;OK. But problem is that object MyDoc have many fields (70 fields). And "switch" become to big. (70 setXXX methods). Can I set fields to object MyDoc without "switch"?

    johndjr wrote:
    Just don't use a switch. It is not really helping any in this case.
    you can just do all the calls explicitly.
    Like so
    myDoc.setField1(list.get(0));
    myDoc.setField2(list.get(1));
    myDoc.setField70(list.get(69));I might convert the list to an array first simply because it seems more natural to me.
    I'm not too sure if it really matters all that much if list is an ArrayList.
    String[] values = list.toArray();
    myDoc.setField1(values[0]);
    myDoc.setField2(values[1]);
    myDoc.setField70(values[69]);you should check that toArray() call, I might not have the correct method I'm kind of doing this off the cuff.I think it is second thoughts day.
    I don't like the hard coded numbers. what I wrote should have defined constants for those values.
    static final int FLD1 = 0;
    static final int FLD70 = 69;
    String[] values = list.toArray();
    myDoc.setField1(values[FLD1]);
    myDoc.setField2(values[FLD2]);
    myDoc.setField70(values[FLD70]);
    Edited by: johndjr on Apr 17, 2009 1:33 PM
    forgot the constants

  • Jdbc getting data from multiple tables

    hi guys
    how can i get data from multiple tables in MSAccess
    please help

    >
    here is code thata i want to do
    i have 3 tables in my MSAccess databace
    Stud_O which consist name,surname fields
    Stud_I consist address,tel
    Stud_E department,faculty fields
    Based on this I would guess that you are missing a key field. There is no way to connect the tables.
    I make the class to insert data to the tables. But
    cant do getting datas from this tables.
    can anybody help me in making query
    and method that displays reultset strings to the
    textBoxes
    A select ...
    select name,surname from Stud_O. Use the executeQuery() method.

  • Help: getting data from a web page

    i have a jsp page which generates some strings. i pass these strings in to a login page on some server. the web page displays my login status. is it possible to read or get data from the web page?
    i have captured the header of a web page and modifying the header based on my generated strings.
    or jus say is it possible to read whats in a web page into a jsp page?
    thanks in advance for any help , assistance or redirection to a source where i can find help.

    hi,
    sorry for a poorly framed question.
    this is what i m trying to do.
    i call google with a header generated.
    now i want to read back the content in the google search result page onto my jsp page.
    possible?
    first.jsp calls google. i m using redirect (url)
    the url is modified based on user input
    now i want the links in the google page to be put up in my page itself. so i want to read the links there...
    Message was edited by:
    on_track

  • Help get data from socket

    hi all
    i am trying to get data from socket www.yahoo.com site and try to write in file with following code
    NOTE:here netClient is the soccket object accepted by server
    File f=new File(finalpath);
    BufferedReader fromClient = new BufferedReader(new InputStreamReader(netClient.getInputStream()));
    OutputStream fo=new FileOutputStream(f);
    String str;
    try{
    while((str=fromClient.readLine())!=null){
    byte buf[]=str.getBytes();
    fo.write(buf);
    }catch(Exception e){}
    finally{fo.close();}
    But i am not getiing data from socket
    please help
    regards krunal

    GeneralYerevan is absolutely right. Use URLConnection and you will get what you want. It seems to me that you do not know deeply how http works. The fact that you opened a connection to www.google.com doesn't mean that you will get data. The web server, after it accepts the socket object, waits for your request. In you case it is something like "GET / HTTP1.1", which you have to write to the stream. URLConnection does all this for you and all you have is to read the InputStream.

  • How to get data from crosstab or table?

    hi !
    i develop my app with bib 9.0.3.1 . To customize my report,i must get data from crosstab or table component (presentation bean) and generate defined XML file ,can you tell me how to do ?

    hi paul
    the sample code like this:
    try{
         DataAccess dataAccess = thinDataview.getModel().getDataAccess();
    int rowCount = dataAccess.getEdgeExtent(DataDirector.ROW_EDGE);
    int colCount = dataAccess.getEdgeExtent( DataDirector.COLUMN_EDGE );
         for ( int i=0; i<rowCount; i++ )
         for( int j=0; j<colCount; j++ )
                   String dataValue = dataAccess.getValue( i,j,DataMap.DATA_UNFORMATTED).toString();
    }catch( Exception e ){
    System.out.println( e.getMessage() );

  • Getting data from mysql!!  please could someone help me?

    Hello people!!
    I can't get data from a Mysql database through a jsp page, there's a error message of conversion,
    here's my classes:
    package teste;
    public class GetDB {
        String str;
        Connection con;
        ObjectPage ob;
        public GetDB()throws Exception {       
            try {
                Class.forName("org.gjt.mm.mysql.Driver");
                con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/Loja?user=root&password=131283");            
            } catch (Exception ex) {
                throw new Exception("Banco de dados n�o encontrado" +
                    ex.getMessage());
        public ObjectPage getOb(){
            try {
                String selectStatement = "select * from teste";
                PreparedStatement prepStmt = con.prepareStatement(selectStatement);
                ResultSet rs = prepStmt.executeQuery();
                while (rs.next()) {
                   str = rs.getString(1)+" "+rs.getInt(2);
                prepStmt.close();
                ob = new ObjectPage(str);
            }catch (SQLException ex) {           
            return ob;
        public void setOb(ObjectPage ob){
            this.ob = ob;
    }    and this:
    package teste;
    public class ObjectPage {
       String name;
       public ObjectPage(String nome) {
           name = nome;
       public String getName(){
           return name;
    }and this is myjsp page:
    <jsp:useBean id="dado" class="teste.GetDB" scope="page" >
      <jsp:setProperty name="dado" property="ob" value="{$name}"/>
    </jsp:useBean>
    <%--<jsp:getProperty name="dado" property="propName"/> --%>
    <p><b><h1><font color="orange">${dado.ob.name}</font></h1></b></p>so what's wrong? could you give me some tips? what should i do ?
    Thanks a lot!!!

    If there's an error message of conversion, are you sure that the 1st and 2nd columns returned in the result set are of type string & integer respectively (try getObject, then see what it's an instanceof)? Just guessing, maybe the actual database fields don't match the types you're expecting.
    And why don't you try ex.printStackTrace() to see what the actual error is in the getOb method?

Maybe you are looking for