List of Like condition from one Lookup table.

Hi,
I have 2 tables.
SourceData table and LookUp table .
SourceData table has one column called SName
SName
Jayesh  Krishnan
Karthik Kumar
Liju    Sharma
Kumar Jayesh
Kumar Pradeep
Lookup table has one column called LName(Lookup table is the one which is required to look up with "like" condition)
LNamne
Kumar%
%Krishnan
I need to query SourceDate table with the like condition mentioned in lookup table.
So my result based on above two tables should look like
Jayesh  Krishnan
Kumar Jayesh
Kumar Pradeep
Please help me in this regard.

Try this,
create table sourcetable (SName varchar(200))
insert into sourcetable values('Jayesh Krishnan')
insert into sourcetable values('Karthik Kumar')
insert into sourcetable values('Liju Sharma')
insert into sourcetable values('Kumar Jayesh')
insert into sourcetable values('Kumar Pradeep')
create table lookuptable (LName varchar(200))
insert into lookuptable values('Kumar%')
insert into lookuptable values('%Krishnan')
go
declare @sql nvarchar(max)
declare @temp table ([where] nvarchar(max))
declare @where nvarchar(max)
set @sql = 'SELECT Substring(COLS,4, LEN(COLS)) FROM (
SELECT Stuff((SELECT '' OR SName like '''''' + LName + ''''''''
FROM lookuptable
FOR xml path('''')), 1, 1, '''') COLS
) X'
insert into @temp exec sp_executesql @sql
select @where = [where] from @temp
set @sql = 'SELECT * FROM sourcetable WHERE ' + @where
exec sp_executesql @sql
go
drop table sourcetable
drop table lookuptable
Regards, RSingh

Similar Messages

  • Copy items(like task list, pages..) from one workspace to anothe

    How do I copy items(like task list, pages..) from one workspace to another?
    I am the admin for both the workspaces, but I am not the oracle workspace administrator.
    Thank you

    Anonymous,
    No this is not a bug. Working with multi-select lists or any item which stores colon delimited values can be tricky to work with in APEX. There are a few work arounds for this. One is to replace the colons with something else like you described and then replace the colons on the landing page. Another solution is to send the primary key for that record and have an automatic row fetch or a computation pull the colon delimited value.
    Cheers,
    Tyson Jouglet

  • How do I copy recordsets from one database table to another?

    I am using the Database Connectivity Toolset, and would like to copy either one recordset or multiple recordsets from one Access table to a table in a different database. I would like to do it directly with the data in variant form, but I can't get it to work. I can get it to work(on a small test table) if I first convert my source variant data to a cluster, then insert that into the other database table. My real database has many items with a variety of date types. Can I copy directly variant to variant?

    Is it necessary to read all the data back into LabVIEW first? The reason I'm asking is that it is much more efficient to just use SQL statements to get the data you need and write that directly to the second database. I did a quick Google search on it and came up with lots of responses on what the correct syntax is for setting that up. Using an SQL command to copy the data back and forth is analogous to copying data from one file to another using the Copy file function rather than reading the entire contents of the file, converting the file string to the data arrays, converting back to a string, and then writing it back to another file.
    Chapter 5 of the Database Connectivity Toolset User Manual describes how to execute SQL queries.
    If you do need to actually
    see the data in LabVIEW first, then the only way to get it back into the other database is to convert those variants to LV datatypes and then cluster those values again and write them back out to the second database.

  • How to insert select columns from one internal table to another

    Hi,
    How to insert select columns from one internal table to another based on condition as we do from a standart table to internal table.
    regards,
    Sriram

    Hi,
    If your question is for copying data from 1 int table to other ;
    we can use
    APPEND LINES OF it_1 TO it_2.
    or if they have different columns then:
    loop at it_1 into wa_it1.
    move wa_it1-data to wa_it2-d1.
    apped wa_it2 to it_2.
    clear wa_it2.
    endloop.
    thnxz

  • How to copy the Pricing conditions from one Distribution Channel to another

    Generally we use VK11 transaction to create conditional records .
    but I Need to Know whether is it Possible to copy the Pricing conditions from one Distribution Channel to another with same name and same internal Characteristics .
    Since we have around 70+ of Condition type with different parameter Sequence.So Instead of Going for BDC whether is there any standard Funct Modules/programs/BAPIs to do this?
    How to make a copy Condition types from One Distribution Channel to another.
    since SAP has already provided to copy conditions from Customer to customer.
    Likewise i need to know whether SAP is facilitating for these feature also.
    Iam Dubious in this issue.
    Hope Fully looking for the answers.
    Harish.N

    - IDOC_INPUT_COND_A (you can create IDOC, but also call directly)
    - call transaction / batch input (use transaction XK15, as used by LSMW)
    - use group of function modules RV_CONDITION_COPY, RV_CONDITION_SAVE, RV_CONDITION_RESET + commit.
    if you search SDN on 'RV_CONDITION_COPY' you'll find more info I believe.
    Someone mentioned BAPI_PRICE_CONDITIONS as well.

  • How to scan data from one internal table to another

    Hi All,
    let me know how to scan all from one internal table to another internal table. Pls provide me the syntax and code.
    i am very thankful to you all in advance.
    Thanks & Regards,
    Nagarjuna.

    if u want to copy data from itab1 to itab2  then use
    itab2[] = itab1[].
    if u want to compare whether both itab1 and itab2 are same or not,use
    if itab1[] = itab2[].
    *--same
    else.
    *--not same
    endif.
    if u want to compare itabs based on primary key....
    loop at itab1.
    read table itab2 with key f1 = itab1-f1.
    if sy-subrc <> 0.
    *--not same....
    endif.
    endloop.
    if u want to copy only few lines(say from 1 to 3) of itab1 to itab2 then use...
    append lines of itab1 from 1 to 3 to itab2.
    if internal tables don't have same structure,
    say only fields f1 and f2 are common,then
    loop at itab1.
    itab2-f1 = itab1-f1.
    itab2-f2 = itab1-f2.
    append itab2.
    clear itab2.
    endloop.
    if there are many common fields then...
    loop at itab1.
    move-corresponding itab1 to itab2.
    append itab2.
    clear itab2.
    endloop.
    Please don't forget to reward points....!!!
    Regards
    vasu

  • How do I print a list of my events from one of my calendars for tax purposes?

    How do I print a list of my events from one of my calendars for tax purposes?

    I actually began this process by creating a new calendar called "Medical" and then each event was assogned to this calendar but the program still wants to print out every day of the month for even those days that have no events.  The list view gives me the look I want and I have even tried deselecting all of the options and then reselecting them one at a time to no avail.

  • To transfer data from one db table to anotherdb's table

    I have to transfer data from one db table A to another db table B.
    Both the tables have data which is common.
    I want to transfer data from table A to table B.
    Data transfer needed is only the excess data in table A

    Yes it works from one database to another by means of db links, but you should be aware that there it has been reported a bug with this environment:
    Bug 4311273 - ORA-2064 using MERGE statement over a database link
    Doc ID: Note:4311273.8
    Executing a MERGE statement over database link can
    fail with ORA-2064
    There are patches for this, but I suggest you to verify at metalink patch availability according to your Oracle version and OS platform.
    ~ Madrid

  • How to assign tasks in Approval Workflow to a set of users selected from a Lookup table

    Hi all,
    I am new to Project Server and I am using Project Server 2013 On premises deployement. Please help me on how to achieve the below scenario:
    I have a requirement where, the initial PDP will have 2 fields (Reviewers and Approvers), wherein the engineer himself will select who the reviewer and approver from the Lookup tables.
    Now I have to start task process with these selected people for approval.
    Say for example , engineer has selected Alice and Bob as 2 reviewers, then
    In the workflow I have :
                 Start Task process with
    Project Data: Reviewers (which is giving error as
    [System.ArgumentException: AssignedTo at Microsoft.Activities.Hosting.Runtime.Subroutine.SubroutineChild.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager
    bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) ]
    Then I tried logging the value of Project Data: Reviewers, It logged the value as Alice, Bob (which looks pretty good),
    Then I tried assigning only 1 person as Reviewer, then also I get the same error.
    So can anybody please tell me where I went wrong. Is it not possible to fetch the data from the values selected as Project Data from the Lookup tables ? If not then what is the workaround I can use to achieve this ?
    Thanks,
    Shanky

    Hi Paul,
    Yes I am using SP designer for Workflows. And yes, You were right, there was a mismatch in the names of AD account and the Lookup table, now with 1 person selected from the lookup table it is assigning the task properly. However with multiple selection,
    it is failing.
    As Robert mentioned, the fetched value is a text as "Alice, Bob", which makes 2 usernames as a single text. So when I try to assign a task to this group, which returns value as "Alice, Bob", workflow fails to find such AD user, as it
    is an invalid value.
    So is there any way I can seperate this out to form 2 different username ? I checked for string extraction function in th Workflow, but nothing helped me for this scenario.
    Any input will be helpful.
    Thanks,
    Shanky

  • 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

  • Extracting from table based on conditions from two internal tables

    Hi,
         i to have select few records from  a table based on conditions from two different internal tables. How can I achieve this.?
    ex:
          select objid from HRVPAD25 into table t_pad25
                                                    where PLVAR = 01
                                                                OTYPE = E
                                                                OBJID = itab1-sobid
                                                                sobid = itab2-pernr.
    How can this be written? can i use "for all entries..." addition with 2 tables?

    Hi Maansi_SAP,
    you can use exactly one internal table in the FOR ALL ENTRIES clause. Consider this alternative:
    data:
      itab_sobid_hash like itab1 with unique key sobid,
      ls_pad25  like line of  t_pad25.
    sort itab1.
    delete adjacend duplicates from itab1 comparing sobid.
    itab_sobid_hash = itab1.
    select objid
      into ls_pad25
      from HRVPAD25
      for all entries in itab2
      where PLVAR = '01'
        and OTYPE = E
        and sobid = itab2-pernr..
    read table itab_sobid_hash with table key sobid = ls_pad25-objid.
    check sy-subrc = 0.
    append ls_pad25 to t_pad25.
    endselect.
    You may decide if itab1 or itab2 is better used as hashed table. Make a performance test.
    The critics will tell you that SELECT ... ENDSELECT is not performant. That was very true, back in last milleniums's 90ies
    Regards,
    Clemens

  • Populate 2 infoobjects from One database Table

    Hi,
    I have two infoobjects INOBJ1 & INOBJ2 & one database table TABLE1(on SAP systems connected via UDI) having fields F1 F2 & description D1.
    I would like to extract data & populate either INOBJ1 or INOBJ2 with F2,D1 data based on field F1.
      Please let me know the fastest & easiest way to do this.
      Thanks & warm regards,
      Sunil

    Hi sunil,
    Write piece of ABAP code based on what condition you want..to fetch the field F2 from table1..
    Check the standard generic extractor for template..
    your case..
    select F2 D1 from table1...where F1 = "condiiton"..
    Regards
    Manga(Assign points)
    Message was edited by: Manga

  • Copying information from one repeating table to another repeating summary table?

    Hi,
    I have designed a dynamic form with a Table 1 (Investigator details) to be completed at the start to provide a list of investigators. This is a repeating table, and I have added buttons to add / delete an investigator (i.e. add/remove a row). I also have another repeating Table 2 at the end of the form to allow the investigators to be listed so they can insert a signature image (signature table).
    Is it possible to set this up so that when one adds an investigator (row) in Table 1, a row is added automatically to Table 2? I then want the Title First name last name to copy into the "Investigator Full name" cell in Table 2. Can this be done and keep the automatic renumbering of the rows in both tables?
    I am not sure how to upload a file to show you what I have, so please let me know and I can send a copy directly.
    I would appreciate if anyone has any suggestions for a code to do this.
    Regards
    Souheir

    Hi,
      Check the code below
    Data: itab1 type table of tab1,
          itab2 type table of tab2.
    * itab2 is of new table type created from some fields of tab1
    * In the select statement below you can select few fields depending upon your requirement
    select * from tab1 into table itab1.
    loop at itab1 into wa1.
      wa2-f1 = wa1=f1.
      append wa2 to itab2.
    endloop.
    insert itab2 into tab2.
    Regards,
    kinshuk
    PS: Reward points if you find it helpful

  • HOW TO TRANSFER DATA FROM ONE INTERNAL TABLE TO ANOTHER

    FOR PERTICULAR OBJECT ID ONE INT TABLE JTAB CONTAINS ONE RECORD(ROW) AND ANOTHER INT TABLE KTAB CONTAINS 3 RECORDS(ROWS). THEN HOW I SHOULD TRANSFER DATA FROM KTAB TO JTAB? WHAT R THE VARIOUS WAYS TO DO THAT. PLS HELP ME OUT. THANKS IN ADVANCE

    Try something like
    If you want one record per ktab :
    LOOP AT jtab.
      MOVE-CORRESPONDING jtab TO itab.
      LOOP AT ktab WHERE id = jtab-id.
        MOVE-CORRESPONDING ktab TO itab.
        APPEND itab.
      ENDLOOP.
    ENDLOOP.
    or
    LOOP AT ktab.
      READ TABLE jtab WITH KEY id = ktab-id. " binary implicit if sorted type
      MOVE-CORRESPONDING jtab TO itab.
      MOVE-CORRESPONDING ktab TO itab.
      APPEND itab.
    ENDLOOP. 
    If you want to sum ktab ratio into itab for each jtab
    LOOP AT jtab.
      MOVE-CORRESPONDING jtab TO itab.
      LOOP AT ktab WHERE id = jtab-id.
        ADD-CORRESPONDING ktab TO itab.
        APPEND itab.
      ENDLOOP.
    ENDLOOP.
    Use sorted type table when LOOP AT WHERE, else SORT table is enough.
    Regards

  • In InCopy, how can I paste from one InDesign table to another without also copying formatting?

    I'm attempting to paste information from one indesign document to another, but the styles are different. Pasting without formatting not working in a table. When I paste over, it retains the container style from the original table.
    I have "Text Only" selected from my Clipboard Handling preferences, so I'm not sure what else to do. I know I can hit escape to switch to the text selection instead of a container, but this only selects the text from one cell. I'd like to copy over the entire table, instead of copying cell by cell.
    How can I paste a table into another, without copying the formatting?

    Copy/Paste whole cells will always retain formatting.
    What you have to do is: Copy/Paste Without Formatting the text contents of the individual cell.
    You have to do that individually for each cell, if you want to copy over text of a whole table.
    A better approach would be to:
    1. Copy the whole table to Excel (or a different spread sheet application)
    2. Copy again from that
    3. Select one single cell and paste
    In that case "Text Only" should be selected from the Clipboard Handling Preferences.
    Uwe

Maybe you are looking for

  • Adobe Cloud creative deployment

    Anyone have any advice for installing adobe creative cloud package? They gave us a packaging program that creates and MSI of all of our adobe products. Everything does install fine but with the exception of adobe acrobat. So I pulled it out of that p

  • Unable to add Lion compatible printer Canon iP4500

    Hello. Having problem to re-install my Canon iP4500 printer. It was running well for years, but I had some issues (USB cable disconnected was the problem ) and deleted the printer to re-install it, all in System Preferences. The problem is that when

  • Error trying to install Turnkey LiveCycle Server with JBoss

    Hello, I'm trying to install a trial of LiveCycle server 11.0.1 on my PC with Windows 7 Enterprise OS, 8GB RAM, 64 bit.  I've successfully done the installation plus the patch, but get the following error when trying to complete the configuration via

  • Display problem

    Product name-15-p001TX Operating systems-Windows 8.1  Respected to whom so ever is concern,      In my notebook pc i have an display problem, some times while working on it, it blinks automatically. sometimes it is bright and some times it is lite. T

  • Simple Java Web Server

    I am looking for a simple Java Web Server similar to the one Sun used to have. My understanding is that they stopped supporting that server. My background for this need is a classroom setting that teaches servlets and JSP, but does not want to specif