Wildcard in SP parameter

I have field called UnitNumber, consisting of a letter suffix and up to 7 digit numerical sequence. Example: G0008591
I'm trying to use wildcard in my procedure to account for a user sending the prefix and dropping leading zeros. User may type G8591
(a.UnitNumber
like
'%'+@unit
+'%')
I'm calling this procedure using SSRS. What am I missing?
.samuel

Try
REPLACE(a.UnitNumber,'0','') like '%'+@unit +'%')
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence

Similar Messages

  • Crystal Reports - Wildcard in Command parameter

    This is what i use now
    {Command.COUNTRY} like {?Country}
    ?Country is a value entered by the user, this could be upper case or lower case and could be part of the country name.
    What is the crystal reports equivalent to achieve the above.
    something like
    caseinsensitive {Command.COUNTRY} like {%?Country%}
    CStr did not work do did
    {Command.COUNTRY} like  '%'{?Country}'%'

    Things are a little different in CR...
    #1) The wildcard you're looking for is "*" not "%"
    #2) Use the "&" to concatenate strings. Save the "+" for addition
    #3) Using a hard coded string, the formula would look like this...
    {Command.COUNTRY} like "*erman*"
    #4) Unfortunately, sticking wildcard characters to either end of a parameter doesn't work the same as it does with hard coded values.
    #5) Fortunately, you're using a command... So #4 doesn't matter... Assuming of course that you are trying to create a record selection formula.
    #6) You're do doing your record selection in the wrong place... If you're using a command, you need to add the parameter to the WHERE clause of your SQL query...Again, working with the assumption that this is for record selection.
    #7) How to accomplish #6...
    - 1) Right click and choose Edit... to open the command in edit mode.
    - 2) Add the parameter to the parameter list. Make sure to spell it EXACTLY the same as you have it spelled in the designer (otherwise you'll create a 2nd, unrelated parameter)
    - 3) Add or modify the WHERE clause to the command SQL. In your case (assuming MS SQLServer based on the syntax you posted).
    It should look something like this...
    WHERE TableName.Country LIKE '%{?Country}%'
    CR will drop the parameter values into the SQL replacing the parameter name with the parameter value before sending it to the server. No need to write dynamic SQL!!!
    The code sent to the server would look something like this...
    WHERE TableName.Country LIKE '%Germany%'
    #8) If you're wandering why it matters or why you don't want to use the Selection Expert when using a command?
    Answer: When you use a command, CR is no longer able to push it's logic back to the server. So the command will pull EVERY record without any filtering back to your local workstation where it will be filtered locally. Adding the where clause to the command itself avoids the issue altogether.
    HTH,
    Jason

  • Using a Wildcard in a parameter

    I have a report with a lastname parameter and a firstname parameter that will prompt user to enter last name and first name.
    The firstname field could have multiple characters such as "Mary Jane".  When I enter the firstname as such, CR could not find the record. It appears that the parameter does not take multiple characters as input.
    Can anyone share a sample on how to create a parameter for this scenario? Can we use a wildcard on the parameters that look something like this:
    Last Name Prompt: lastname
    First Name Prompt: firstname*
    Thanks in advance

    I found out that it's the way the data was entered into the database. Because there is more than 1 space between the 2 characters (ex: Mary   Jane), unless I  enter it exactly like that in the prompt, it won't be able to find the record.
    The challenge is I can not predict how the names look like in the database. Is there a way to use wildcard for a partial search such as Mary*  so that all instances of Mary will return?
    I was able to setup wildcard for the firstname field so that ALL records will return but this is not a viable solution as there could be too many rows.

  • Use wildcards or type parameter?

    Hello all,
    please consider these declarations:
    interface TaskListener<T>
    // methods omitted for clarity
    interface Task<T>
    void addTaskListener(TaskListener<? super T>  listener);
    // other methods omitted for clarity
    }I was trying to implement the interface TaskListener as shown below, and I found that only version 2 compiled, whereas version 1 did not. Shouldn't these two be equivalent?
    class TaskGroup<T> implements TaskListener<T>
    // Version 1 (does not compile)
    public void addTask(Task<? extends T> task)
    task.addTaskListener(this);
    // other code omitted for clarity
    // Version 2 (this one compiles)
    public <S extends T> addTask(Task<S> task)
    task.addTaskListener(this);
    // other code omitted for clarity
    }

    Yes, they should be equivalent. We're working on it.Cool!
    So the whole "wildcard stuff" is at least soundly integrated into the Type Parameter System and can even be understood by humble programmers like myself ;-)
    And thanx for the quick reply!

  • CreateQuery() using LIKE and % wildcard: wrong parameter Name :(

    Hi, I cant find an example of an EJB-QL that uses a LIKE statement and wildcards surrounding a parameter.
    I`d tried this:
    queryString = "SELECT p FROM Prestadores p WHERE p.nombre LIKE '%?1%'"and also:
    queryString = "SELECT p FROM Prestadores p WHERE p.nombre LIKE '%:nombre%'"in ths code.
    try {
                Query q = em.createQuery("queryString");
                //q.setParameter(1, nombre);
                q.setParameter("nombre", nombre);
                listaPres = q.getResultList();
                cargarBusquedaPrestadores(listaPres);
                return listaBPres;
            } catch (Exception e) {
                System.err.println("PrestadoresBean.getDatosPestadorxNombre(String Nombre) Exception Inesperada");
                System.err.println(e.getMessage());
                return null;
            }but i get:
    You have attempted to set a parameter at position 1 which does not exist in this query string SELECT p FROM Prestadores p WHERE p.presNombre LIKE '%?1%'or
    You have attempted to set a parameter value using a name of nombre that does not exist in the query string SELECT p FROM Prestadores p WHERE p.presNombre LIKE '%:nombre%'.respectively from the SUN App server log.
    any help would be appreciated.
    Thanks in advance!

    If you use wildcards inside parameters and fix other bugs the problem will disappear.
    Try this:
    queryString = "SELECT p FROM Prestadores p WHERE p.nombre LIKE ?1";  //quotes aren't necessary
    Query q = em.createQuery(queryString); //Of course there can't be "queryString"
    q.setParameter(1, "%" + nombre + "%");
    listaPres = q.getResultList();

  • SQL Command - Paramater and wildcard

    Post Author: edy80y
    CA Forum: Crystal Reports
    Hi All,
    I have successfully dumped an SQL into a 'Add Command' function and it returns the data exactly how i want it.  But now i want to add a parameter so that i dont have to manually update the date which is referenced 8 times.
    The TIME_KEY field is in this format YYYYMMDDHHMMWST (for 20/12/2007 2:30PM) = 200712201430WST
    I have used LIKE '20071220%' so it returns all rows within that one date.
    Now, i created a string parameter {?date) so i can enter '20071220' and i want to attach the wildcard (%) to the parameter.
    If i do any of the following it doesn't work:
    LIKE {?date} + '%'
    LIKE {?date} || '%'
    LIKE {?date} & '%'
    Here is the code:
    SELECT    "T1"."OBJECT_ID", "T1"."TIME_KEY",                          (SELECT     SUM("N_ANSWERED") AS "ANSWERED_ROLLING"                            FROM      "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2"             WHERE      "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'),                           (SELECT     SUM("N_ABANDONED_RING") AS "ABANDONED_RING_ROLLING"                            FROM          "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2"                            WHERE      "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'),                           (SELECT     SUM("N_ABANDONED_QUEUE") AS "ABANDONED_QUEUE_ROLLING"                            FROM          "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2"                            WHERE      "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'),                           (SELECT     SUM("N_ENTERED") AS "ENTERED_ROLLING"                            FROM          "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2"                            WHERE      "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'),                           (SELECT     SUM("N_ABANDONED_SHORT") AS "ABANDONED_SHORT_ROLLING"                            FROM          "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2"                            WHERE      "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'),                           (SELECT     SUM("N_ANS_IN_THRESH") AS "ANS_IN_THRESH_ROLLING"                            FROM          "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2"                            WHERE      "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'),                           (SELECT     SUM("N_ABANDONED") AS "ABANDONED_ROLLING"                            FROM          "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2"                            WHERE      "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%')FROM        "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T1"WHERE  "T1"."TIME_KEY" LIKE '20071220%'GROUP BY "T1"."OBJECT_ID", "T1"."TIME_KEY"ORDER BY "T1"."OBJECT_ID", "T1"."TIME_KEY"

    Post Author: yangster
    CA Forum: Crystal Reports
    putting the parameter within a single quote is incorrect if it is a string as it will look for a litteral reference to {?date} instead of the valueLIKE {?date} || '%'that should work np as you are con catting a string to another string with 0 to infinite number of characters followingwhat db are you using?

  • EJB QL "LIKE" OPERATOR NIGHTMARE

    i want to pass input parameter to my ejb ql.
    it will look like this :
    "SELECT OBJECT(p) FROM EntityBeanTable p WHERE p.Title LIKE ?1"
    But it seem its imposible with ejb 2.0. am i right ?
    how to overcome this then,
    "LIKE" operator is so damn important, without this we can't continue our development.
    shall we use bmp ? or ????

    You can use the like operator with parameters, you just have to put your wildcards into the parameter. Here's an excerpt:
    A query that uses a LIKE operator would look something like this:
    SELECT DISTINCT OBJECT(user)
    FROM User user
    WHERE user.userInfo.lastName LIKE ?1
    If you check out the code in the code listing on the left-hand side of this panel, you will
    note that a method exposes this functionality from the UserManagement session bean
    so that you can access it from the client with the getUserByLastNameLike()
    method. Thus, to use getUserByLastNameLike(), you can specify the pattern
    string as a parameter.
    For example, to find users with last names like "High", you would pass the following
    parameter value:
    users = userMgmt.getUserByLastNameLike("High%");

  • Can you safely cast Object to generic Set MyType ?

    I have a property change event evt where evt.getNewValue() contains a Set<MyType> value and I want to do the following:
    Set<MyType> newSet = (Set<MyType>)evt.getNewValue();
    Is there a "safer" way of doing this which satisfies the compiler enough to prevent the unchecked warning?
    Before going any further and replying with something like MyType<T> is lost at runtime, I want to add that I can do:
    MyObject<MyType> myObj = new MyObject<MyType>();
    as well as:
    MyObject<MyType> myObj = createMyObj(MyType.class);
    {.. and somewhere alternatively: return clazz.cast(o); }
    So why can't I do something similar with Set<MyType> such as:
    Set<MyType> newSet = Set<MyType>.class.cast(evt.getNewValue()); // compile error obviously.
    I suppose I'll just have to go with:
    Set newSet = (Set)evt.getNewValue();
    for (Object o : newSet)
    MyType myType = MyType.class.cast(o);
    }

    This would only be helpful, if one also changes the PropertyChangeListener interface topublic interface PropertyChangeListener<T> {
      void propertyChange(PropertyChangeEvent<T> evt);
    }making it parametrized by the Type of values so the listener can receive type-safe events. If you don't, you will have the same problem as the OP with casting to the parametrized event type.
    Same, if one only uses a wildcard for the parameter's type.
    Of course, doing so is possible for your own classes, if you do not have to be compatible with any Swing or AWT code. One would have to implement specific listeners for each type of evented value, though, as it is not possible to implement the same interface more than once having different parameterizations. It seems by far more overhead and complex than simply checking and casting the value received by the event.

  • SERVER_CACHE_INVALIDATE?

    Hello,
    I am trying to find a way to remove a certain item from the ICM server cache.
    I want to use the following function :
    <i><b>CL_HTTP_SERVER=>SERVER_CACHE_INVALIDATE( id      = cache_id
                                             type    = 0
                                             scope   = 0 ).</b></i>
    but I don't know how to find the cache key.
    On this page (
    http://help.sap.com/saphelp_webas620/helpdata/EN/38/2d453cf1fcc85ee10000000a11402f/content.htm)
    it is explained.
    <b>QUOTE :</b>
    <i>The URL path is translated, that is, the encoded information about the SAP language and SAP theme, separated by & symbols, is added after the ICF path. This is then followed by another & symbol and the query string with the pseudo query parameters. To restrict the length of this string, a <b>hash process</b> is used on the query string.</i>
    I would like to know how this <b>hash process</b> actually works?
    Message was edited by: Dries Horions

    I don't think that the processing of the query string described in the help document is not the same thing that is taking place to the URLs in your ICM Cache.  This help refers to the URL mangling that takes place like the following:
    kww-d15s.kimball.com/sap(bD1lbiZjPTA4OA==)/bc/bsp/sap ....
    Whatever that ending part is, it is appended automatically.  I have some code that forces some content into the cache:
    cl_http_server=>server_cache_upload( url      = url
                                           response = cached_response ).
    When I look at this in the Cache Monitor I see &en&&A6E90000& appended to the end of the URL.  The &en& is for the language this object is intended for.  I assume that items beginning with the &&& are not lanuage specific. 
    However I can also see that if I call the SERVER_CACHE_INVALIDATE method and wildcard the ID parameter with my URL + * it does properly clear my item. I don't know if this helps you out or not.

  • CCMS File Monitoring - Autoreaction for every new File

    Hi Experts,
    I have a folder with xml files. I monitor these files with the sapccmsr agent. this works fine. Now I want to establish an alerting for the files. If in one of these files contains the pattern "error", I want to generate an alert. I have generated a logfile template like here:
    LOGFILE_TEMPLATE
    DIRECTORY="E:/usr/sap/prfclog/sapccmsr/Test/"
    FILENAME="*.xml"
    MONITOR_FILESIZE_KB=1
    PATTERN_0="Error"
    VALUE_0=RED
    if in a file the pattern "Error" exists the colour in rz20 is changed to red. this is working ...
    now I come to my problem:
    the names of the monitored files are changing. for example there is a file with the name "file_0.xml". the next day a new file with the name "file_x.xml" exists. so, for the alerting with autoreaction it is necessary that the system gives the autoreaction to each file in the monitor automaticly. is it possible? how can i solve this problem?
    best regards
    christopher

    Hello Christopher,
    > the names of the monitored files are changing. for example there is a file with the name "file_0.xml". the next day a new file with the name "file_x.xml" exists.
    you monitor all theses files. The wildcard in the parameter "FILENAME" ensures this:
    > FILENAME="*.xml"
    > so, for the alerting with autoreaction it is necessary that the system gives the autoreaction to each file in the monitor automaticly. is it possible? how can i solve this problem?
    A short look into the [online documentation|http://help.sap.com/saphelp_nw70/helpdata/EN/cb/0f8897c23b414ab6e562aa913971bc/frameset.htm] returns the parameters AUTOREACTION_LOC and AUTOREACTION_CEN.
    Maybe they will be helpful?
    Regards, Michael

  • Wildcard parameter in Discoverer

    Hello -
    I have set up several parameters in a Discoverer 4i report. For some of the parameters I have set a condition of "LIKE" for the user input. For these parameters I would like the users to have the option of putting in a wildcard value (%) if they want to receive all values for the parameter. Is this possible?

    Hi,
    Database contexts may be able to help you here. Search this site for SYS_CONTEXT or check Re: Passing multiple parameters into Custom Folder...
    Rod West

  • Use a parameter value in F4 help / Implement a wildcard F4 help

    Hi,
    I would like to implement a F4 help for a parameter. The user should be able to enter a text to the parameter field hit F4 and get and help screen related to the text he just entered. (pretty much like the F4 help for SE16 or SE83)
    My problem is, that the entered text is not available in the report.
    REPORT SELECTION_SCREEN_F4_DEMO.
    PARAMETERS: filename TYPE localfile LOWER CASE.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
      CALL SCREEN 100 STARTING AT 10 5
                      ENDING   AT 50 10.
    MODULE VALUE_LIST OUTPUT.
      SUPPRESS DIALOG.
      LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
      SET PF-STATUS SPACE.
      NEW-PAGE NO-TITLE.
      WRITE: 'Pattern:', filename COLOR COL_HEADING.
    * selection of filenames ...
      CLEAR filename.
    ENDMODULE.
    AT LINE-SELECTION.
      CHECK NOT filename IS INITIAL.
      LEAVE TO SCREEN 0.
    If a value was entered at the selection screen and a break point is set in MODULE VALUE_LIST OUTPUT, value filename is always empty.
    How can the current value of parameter filename be accessed in the program?
    Thanks in advance
    Dominik

    You would have to use a form, with hidden parameters and a method="post". Your Next link could be a submit button, or be a link with an onclick event that submitted the form:
    <c:url var="thisURL" value="homer.jsp"/>
    <form name="iqform" action="<c:out value="${thisURL}"/>">
      <input type="hidden" name="iq" value="<c:out value="${homer.iq}"/>"/>
      <input type="hidden" name="checkAgainst" value="marge simpson"/>
      <input type="submit" value="Next"/>
      <!-- or -->
      <script type="text/javascript">
        function submitIqForm() {
          document.iqform.submit();
      </script>
      <a href="javascript: submitIqForm()">Next</a>
    </form>

  • SQL: how to embed parameter inside quotes for wildcard %

    I would like to know how to modify a SQL statement to embed a
    parameter inside quotes. I want to use the parameter inside of a
    statement such as: SELECT * from table WHERE col LIKE '%@parm'
    I can get the query to work without the parameter, just not
    with it?? Is there a CS3 workaround?
    Thanks

    Well, after plenty of trial and error, it appears I had to
    edit the parameter itself.
    and go from this
    Request.Form["TextBox1"] : ""
    to this
    "%" + Request.Form["TextBox1"] + "%" : ""
    yay!

  • How to add item to a List with a bounded wildcard

    Hi,
    Is there a way to add a subtype instance to a List with a bounded wildcard? For example, say I have an
    abstract class called Car. Then I have 2 concrete subclasses--Ford and Toyota. Now say I have another
    class that contains a prepopulated list and is wildcard bounded like this: List<? extends Car> carList. I
    want to add a method where I pass in a Car subtype as a parameter and then add it into this list, e.g:
    public void addCar(Car car) {
    carList.add(car);
    Trying this, I keep getting "cannot find symbol" compilation errors. When I went back to read the Generics
    tutorial by Bracha, he mentions that explicitly adding a subtype, e.g. carList.add(new Ford()), can not be
    done. But here I'm adding the "upper bound" of the wildcard, i.e. the Car type. Therefore there should be no
    discrepancy between supertype and subtype an thus the carList.add(car) should be ok, IMO.
    Am I misunderstanding something with this logic? Also, if carList.add(car) can not be done, then how can
    I go about doing something similar which will allow me to add subtypes to a "generic" list?
    Thanks in advanced!
    -los

    I get a compilation error expecting an Object instead of a Car. Of course you did. List<? super Car> is a list into which you can put cars -- and possibly other stuff. List<? extends Car> is a list out of which you can get cars (possibly of different makes).
    Do you need a list that you can put cars in and get cars out? That's List<Car>
    This isn't a linguistic problem you are having; this is a design problem. If you have a function that takes an argument which is a list that you can put any kind of car into and be sure of getting a car out of, it isn't reasonable to pass in a List<Ford> (because the function might put in a Chevy) or a List<Object> (but there might be motorcycles already in there). By the requirements you have, you need a List<Car> and nothing else.
    Yes, you could use a cast, but all you are doing is circumventing the type system by saying "I know this List<Object> only has Cars in it."

  • Design problem involving Wildcards and EJB-QL.

    Could someone tell me if this is possible? (my syntax might be a bit off, but bear with me. It's the design I'm interested in, not the exact syntax)
    signature="java.util.Collection findByFullMonty (java.lang.Float price, java.lang.Integer bedrooms... "*snip*
    query="SELECT OBJECT(o) FROM Houses o  WHERE ((o.price =?1) AND (o.bedrooms= ?2) AND ... "*snip*I'd like to be able to use this query with wildcards as default values in a fashion similiar to this:
    Float price = ??  ;//This is where i'm unsure, what is a valid wildcard for a Float?
    Integer bedrooms = ??; // same here for Integer....
    String realtorName = "*"; //i think this is valid wildcard for strings
    *snip*
    //if price supplied set price to input value
    if (myObject.getPrice() != null){
        price = myObject.getPrice();
    //if bedrooms supplied set bedrooms to input value
    if (myObject.getBedrooms()!= null){
        bedrooms = myObject.getBedrooms();
    //always use this finder using wild cards  unless a parameter is supplied
    Collection c = findByFullMonty (price, bedrooms,  realtorName, *snip*); What i'm tyring to achieve is a single query that will work no matter how many of the input paramaters are supplied. Any supplied parameters are used, and those that are not supplied will use wildcard instead. I don't want to make a seperate query for every possible permutaion of supplied input parameters. Can this be done? If so, am I even close or out in left field? Is there a design pattern I should look into for this problem?
    Thanks for any help guys!
    (sorry for the cross-post, i didn't realize this was the approprate place until afterwards)

    Yes, that makes sense, but the EJB-QL statements and finder methods in the home interface have to be defined at deployment time, correct? Once it is deployed, I can't dynamically create the EJB-QL statements and finder methods that are needed. That's the major hurdle I have right now.
    Populating a big 'catch-all' query with wild cards and replacing them with supplied literal values is the only way I could think of to accomplish this dynamically. In my current work around I set a flag for each piece of data supplied. I then decide which (pre-defined) query is needed based on the supplied criteria flags. The problem is, I now have to have 2^n (n = number of possible input parameters) permutaions for the possible queries. For example: say i have: price, bedrooms and bathrooms. I'd need queries for the following cases:
    1 price supplied only
    2 bedrooms supplied only
    3 bathrooms supplied only
    4 price and bedrooms
    5 price and bathrooms
    6 bedrooms and bathrooms
    7 price, bedrooms, bathrooms
    8 nothing supplied (return everything)
    Obviously this is going to break down really fast as the number of input parameters climbs.
    Should I look at using some kind of JDBC code directly to build a query as I go? It seems like I am either approaching this the wrong way or missing something really obvious.

Maybe you are looking for