Using MS SQL Like Queries

Hi im running a MS sql database behind my Cold fusion site.
I have a question on like queries that someone here will
probably be able to
help me
I have a query that uses the following code
name like '#search#%'
The word Danger Sign appears as a name in my database.
When I do a search on Danger Signs no records are returned.
However when i do a search on Danger Sign my records are
returned.
I also tried to use
name like '%#search#%'
which also returned no results on Danger Signs
Is the fact that my search term is two words causing the
problem?
Thanks in advance

The ScareCrow wrote:
> If the 2 words "Danger Sign" are in the field and you
search for "Danger Signs"
> then no it will not match it because it does not match.
ken, actually i think that should work. i just tried
SELECT uniLanguage
FROM unicodeTest
WHERE uniLanguage LIKE 'Chinese (%'
and it correctly returned 2 rows (Chinese (Traditional) &
Chinese (Simplified)).
maybe the search term is getting bunged up?
> To be able to do something like you want to do you will
need to look into
> "full text searching" for sql server.
that's good advice. using wild cards in LIKE where clauses
makes sql server do a
table scan instead of using an index (unless the wild card is
at the end of the
search term). ms's full text indexing wins awards for it's
search. i normally
use it instead of verity.

Similar Messages

  • I'd love to see a way to create Smart Playlists with a raw (SQL-like) lang.

    I'm not sure if this is the proper place to put a request, but if any of you developers are out there looking for ideas here's one I (and I'm sure many other power users) would love.
    Give is a way to create smart playlists with nested logic or using an SQL-like query language. Currently when matching multiple properties of songs we have an all-or-nothing approach to AND's and OR's which is quite limiting if you want to do something like.
    "All songs with a rating of 2+ and a genre of electronica or metal"
    Currently the only way to do this is to first create a smart playlists for all songs with a genre of electronica or metal, and then create a second playlist which is songs with a rading of 2+ and in the first playlist.
    While this trickery will allow you to achieve any goal you could imagine, it get's quite messy very quickly.
    It'd be much easier (for someone like me) to just be given a raw interface that would allow me to do something like
    [Songs matching the clause]
    rating > 2
    AND
    genre = 'Metal'
    OR
    genre = 'Electronica'
    AND
    artist 'Iron Maiden'

    Great idea.
    Tell Apple -> http://www.apple.com/feedback/itunesapp.html

  • Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database"

    Hi, Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database" ?
    When I use Connect Object Explorer, the "Connect to Server" dialog box which pops up has only 4 selections in the Server Type Drop Down List. They are Database Engine, Analysis Services, Reporting Services & Integration Services. I have read
    somewhere that there should be a compact database option. but I do not see it.
    What I would like to do is use free form SQL Queries against the tables in "SQL Server Compact 4.0 Local Database" .
    Once I have validated these queries, then I will use them in my Visual Studio 2012 C#, ASP.NET application. I created the Local Database using Visual Studio 2012 for use by my application.
    Thank you for your help..
    diana4

    Hello,
    With SSMS 2005 we have had the Option to work with SQL CE database files, but not with higher Version of SSMS.
    You can use the free SQL CE Toolbax instead; see
    http://sqlcetoolbox.codeplex.com/
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Using a SQL for Oracle in Microsoft Excel Query

    I am having the most difficult time (in fact, I can't get it to work) trying to use an SQL I created in Toad for Oracle. It works fine in Toad for Oracle...gives me all the data I need. I am trying to use it in Excel for users that don't know SQL or Oracle so they can use the query to extract data they need for Charts, Graphs, etc.
    Here is the SQL code from Toad for Oracle:
    /* Formatted on 2006/09/22 11:42 (Formatter Plus v4.8.6) */
    SELECT a_compl_summary.incident_number, a_compl_summary.case_number,
           a_compl_summary.part_sequence, a_compl_summary.part_number,
           a_compl_summary.lot_number, a_compl_summary.alert_date,
           a_compl_summary.entry_date, a_compl_summary.NAME,
           a_compl_summary.MONTH, a_compl_summary.product_family,
           a_compl_summary.complaint, a_compl_summary.reportable,
           a_compl_summary.product_returned, a_compl_summary.case_desc,
           a_compl_summary.failure_invest_desc, a_compl_summary.lhr_search,
           a_compl_summary.root_cause, a_compl_summary.corrective_action,
           a_compl_summary.region,
           rp_qa_reported_device_codes.reported_device_code,
           rp_qa_reported_device_codes.reported_dev_clarification,
           rp_qa_reported_device_codes.reported_dev_code_desc,
           rp_qa_patient_codes.patient_code,
           rp_qa_patient_codes.patient_code_clarif,
           rp_qa_patient_codes.patient_code_severity,
           rp_qa_patient_codes.description
      FROM chsuser.a_compl_summary,
           chsuser.rp_qa_patient_codes,
           chsuser.rp_qa_reported_device_codes
    WHERE (    (a_compl_summary.product_division = 'CP')
            AND (    a_compl_summary.entry_date >= :date1
                 AND a_compl_summary.entry_date <= :date2
            AND (   a_compl_summary.product_family LIKE :pf1
                 OR a_compl_summary.product_family LIKE :pf2
                 OR a_compl_summary.product_family LIKE :pf3
                 OR a_compl_summary.product_family LIKE :pf4
                 OR a_compl_summary.product_family LIKE :pf5
            AND (a_compl_summary.region = :r1)
            AND (   a_compl_summary.NAME = :c1
                 OR a_compl_summary.NAME = :c2
                 OR a_compl_summary.NAME = :c3
                 OR a_compl_summary.NAME = :c4
                 OR a_compl_summary.NAME = :c5
            AND (a_compl_summary.complaint = :yorn)
            AND (   rp_qa_reported_device_codes.reported_dev_clarification LIKE
                                                                              :cl1
                 OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
                                                                              :cl2
                 OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
                                                                              :cl3
                 OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
                                                                              :cl4
                 OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
                                                                              :cl5
            AND (rp_qa_reported_device_codes.reported_dev_clarification NOT LIKE
                                                                              :dc1
            AND (a_compl_summary.incident_number =
                                               rp_qa_patient_codes.incident_number
            AND (a_compl_summary.case_number = rp_qa_patient_codes.case_number)
            AND (a_compl_summary.part_sequence = rp_qa_patient_codes.part_sequence
            AND (a_compl_summary.incident_number =
                                       rp_qa_reported_device_codes.incident_number
            AND (a_compl_summary.case_number =
                                           rp_qa_reported_device_codes.case_number
            AND (a_compl_summary.part_sequence =
                                         rp_qa_reported_device_codes.part_sequence
            AND (rp_qa_reported_device_codes.incident_number =
                                               rp_qa_patient_codes.incident_number
            AND (rp_qa_reported_device_codes.case_number =
                                                   rp_qa_patient_codes.case_number
            AND (rp_qa_reported_device_codes.part_sequence =
                                                 rp_qa_patient_codes.part_sequence
           )Can someone help me...maybe point out what I'm doing wrong.
    Note: I also tried creating this query in Microsoft Query (the simple way) and when I first create it...it works...But then if I go back in to edit the query, and refresh the query or try to Return data to Excel, it gives me a ORA-00936 error message.
    Why it works when I first create the query in Excel, I don't know. But I have to validate the queries I'm creating (SQL or not) and I can't validate it if every time I go into edit the query (which may have to happen; that's why I have to fix this before I can submit my validation).
    Anyway, any help would be greatly appreciated.

    Okay, I know I'm replying to my own threads here...but I want to add a little bit more information again.
    I was successful in figuring out that changing the :criteria to a ? worked.
    I tested this on 1 criteria at a time. Adding one more scenario ? at at time.
    It only worked up until about 3 scenarios of each criteria.
    Then when I refreshed the query in Microsoft Excel Query, I got an "out of memory" error, and then it ended up just erasing the SQL I had been using.
    Here's the SQL I had where it gave me this error. Am I possibly just making Excel work too hard? It just doesn't make sense because Toad for Oracle handled it in like 4 seconds. Which brings me back to an intial question I had. Can Excel use Toad for Oracle somehow?
    Here's the code:
    SELECT a_compl_summary.incident_number, a_compl_summary.case_number,
           a_compl_summary.part_sequence, a_compl_summary.part_number,
           a_compl_summary.lot_number, a_compl_summary.alert_date,
           a_compl_summary.entry_date, a_compl_summary.NAME,
           a_compl_summary.MONTH, a_compl_summary.product_family,
           a_compl_summary.complaint, a_compl_summary.reportable,
           a_compl_summary.product_returned, a_compl_summary.case_desc,
           a_compl_summary.failure_invest_desc, a_compl_summary.lhr_search,
           a_compl_summary.root_cause, a_compl_summary.corrective_action,
           a_compl_summary.region,
           rp_qa_reported_device_codes.reported_device_code,
           rp_qa_reported_device_codes.reported_dev_clarification,
           rp_qa_reported_device_codes.reported_dev_code_desc,
           rp_qa_patient_codes.patient_code,
           rp_qa_patient_codes.patient_code_clarif,
           rp_qa_patient_codes.patient_code_severity,
           rp_qa_patient_codes.description
      FROM chsuser.a_compl_summary,
           chsuser.rp_qa_patient_codes,
           chsuser.rp_qa_reported_device_codes
    WHERE (    (a_compl_summary.incident_number =
                                               rp_qa_patient_codes.incident_number
            AND (a_compl_summary.case_number = rp_qa_patient_codes.case_number)
            AND (a_compl_summary.part_sequence = rp_qa_patient_codes.part_sequence
            AND (a_compl_summary.incident_number =
                                       rp_qa_reported_device_codes.incident_number
            AND (a_compl_summary.case_number =
                                           rp_qa_reported_device_codes.case_number
            AND (a_compl_summary.part_sequence =
                                         rp_qa_reported_device_codes.part_sequence
            AND (rp_qa_reported_device_codes.incident_number =
                                               rp_qa_patient_codes.incident_number
            AND (rp_qa_reported_device_codes.case_number =
                                                   rp_qa_patient_codes.case_number
            AND (rp_qa_reported_device_codes.part_sequence =
                                                 rp_qa_patient_codes.part_sequence
    AND (a_compl_summary.product_division = 'CP')
            AND (    a_compl_summary.entry_date >= ?
                 AND a_compl_summary.entry_date <= ?
            AND (   a_compl_summary.product_family LIKE ?
                 OR a_compl_summary.product_family LIKE ?
                 OR a_compl_summary.product_family LIKE ?
                 OR a_compl_summary.product_family LIKE ?
                 OR a_compl_summary.product_family LIKE ?
            AND (a_compl_summary.region = ?)
            AND (   a_compl_summary.NAME = ?
                 OR a_compl_summary.NAME = ?
                 OR a_compl_summary.NAME = ?
                 OR a_compl_summary.NAME = ?
                 OR a_compl_summary.NAME = ?
            AND (a_compl_summary.complaint = ?)
            AND (   rp_qa_reported_device_codes.reported_dev_clarification LIKE
                 OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
                 OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
                 OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
                 OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
            AND (rp_qa_reported_device_codes.reported_dev_clarification NOT LIKE
               ))

  • Parameterizing a view to use with IN list queries..

    Brief bit of intro:
    I'm writing an app that lets the user create a stored procedure of varying number of arguments. One or more of these arguments will be of the form:
    1,2,3
    'a','b','c'
    Supplied as strings, and without using dynamic sql, it becomes difficult to use them as IN-list arguments because we essentially have the IN operator searching for a record that contains the literal text 1,2,3 rather than looking for records that match on 1 or 2 or 3
    Having done some reading, it would appear that I can pull this trick:
    SELECT
       TRIM(SUBSTR(src, INSTR(src, ',', 1, LEVEL)+1, INSTR(src, ',', 1, LEVEL+1) - INSTR(src, ',', 1, LEVEL)-1)) output
    FROM
       t
    CONNECT BY ROWNUM<=LENGTH(src) - LENGTH(replace(src,','))-1Where src is the string list
    Now thats quite cumbersome, so I'd like to hide it. Tom gives us a way that I dont fully understand, but it seems to basically be of setting an Oracle environment variable of name XYZ to value 'a','b','c' - i.e. our string, and then writing a view that targets the variable.
    My first question is, can someone help me out with a bit of code that does that?
    Is there a problem with using the variable, because what happens if someone else calls this procedure while I am still calling it - is it possible that their call will set my env var to something else before my sql is run? How can I localise the environment variable to me/my session only?
    Also could you provide an example PL/SQL of how it would be used?
    I guess something like:
    PROCEDURE xyz(in_list varchar2)
    IS BEGIN
      set_environment_var(XYZ, in_list);
      SELECT 1 FROM table WHERE inlistcolumn IN (SELECT * FROM in_list_view)
    ENDin_list_view is the view that targets env variable XYZ. Other bits are mainly pseudocode because I dont know how/where to set the environment variable.
    The second question I have is:
    Once I have this in place, am I correct in thinking that I will have to create two views if I wish to write a query that has 2 in-list clauses?
    i.e.
    PROCEDURE xyz(in_list_one varchar2, in_list_two varchar2)
    IS BEGIN
      set_environment_var(XYZ, in_list_one);
      set_environment_var(ABC, in_list_two);
      SELECT 1 FROM table WHERE in_list_column IN (SELECT * FROM in_list_view_XYZ) and other_in_list_column IN (SELECT * FROM in_list_view_ABC)
    ENDFor N in list ops, i must have N queries and N environment variables, yes?

    I've never used Tom's environment variable approach, but here's a different technique you may wish to consider (assuming you're on 10g).
    SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jun 29 15:20:55 2007
    create table t ( n number, v varchar2(10) );
    Table created.
    insert into t values ( 1, 'a' );
    1 row created.
    insert into t values ( 2, 'b' );
    1 row created.
    insert into t values ( 3, 'c' );
    1 row created.
    insert into t values ( 4, 'd' );
    1 row created.
    insert into t values ( 5, 'e' );
    1 row created.
    commit;
    Commit complete.
    -- for numeric in-list
    variable d varchar2(1)
    variable p varchar2(10)
    execute :d := ',' ;
    PL/SQL procedure successfully completed.
    execute :p := '1,2,3' ;
    PL/SQL procedure successfully completed.
    select *
    from t
    where n in
      ( -- this query converts string '1,2,3' into
        -- three rows containing 1, 2, and 3
        select val
        from   dual
        model
          return updated rows
          dimension by ( 0 as position )
          measures     ( :p || :d as val )
          rules upsert
          ( val
            [ for position
                from 1
                to   length( regexp_replace( val[0], '[^'||:d||']', null ) )
                increment 1
            ] = rtrim( regexp_substr( val[0], '.*?' || :d, 1, cv(position) ), :d )
    order by 1 ;
             N V
             1 a
             2 b
             3 c
    3 rows selected.
    -- for string in-list
    execute :d := ',' ;
    PL/SQL procedure successfully completed.
    execute :p := '''a'',''b''' ;
    PL/SQL procedure successfully completed.
    select *
    from t
    where v in
      ( -- this query converts string 'a','b' into
        -- two rows containing 'a' and 'b'
        select val
        from   dual
        model
          return updated rows
          dimension by ( 0 as position )
          measures     ( replace( :p || :d, '''', null ) as val )
          rules upsert
          ( val
            [ for position
                from 1
                to   length( regexp_replace( val[0], '[^'||:d||']', null ) )
                increment 1
            ] = rtrim( regexp_substr( val[0], '.*?' || :d, 1, cv(position) ), :d )
    order by 1 ;
             N V
             1 a
             2 b
    2 rows selected.There are alternatives to using MODEL as well. Check out SQL Snippets: SQL Techniques Tutorials - String to Rows for some other approaches.
    Joe Fuda
    SQL Snippets

  • Issue While executing the Query for Pagination using ROWNUM with like

    Issue While executing the Query for Pagination using ROWNUM with like.
    Database is Oracle11G.
    Oracle Database Table contains 8-9 lakh records
    1) SQL equal (=)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE = 'KMF22600920'
    Execution Time:- 0.00869245 seconds
    Returns 2 resultsets
    2) SQL like (one %)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE = 'KMF22600920%'
    Execution Time:- 0.01094301 seconds
    Returns 2 resultsets
    3) SQL like (two%)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE like '%KMF22600920%'
    Execution Time:- 6.43989658 seconds
    Returns 2 resultsets
    In Pagination, we are using Modified version of SQL Query 3) with ROWNUM as mentioned below :-
    4) SELECT * FROM (
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE REFERENCE like '%KMF22600920%' AND ROWNUM <= 20 ) WHERE RNUM > 0
    Execution Time:- Infinite
    ResultSets:- No as execution time is infinite
    a) Instead of like if we use = in the above query it is returning the 2 resultsets (execution time 0.02699282 seconds)
    b) Instead of two % in the above query, if use one example REFERENCE like 'KMF22600920%' it is returning the 2 resultsets (execution time 0.03313019 seconds)
    Issue:- When using two % in like in the above query i.e. REFERENCE like '%KMF22600920%' AND ROWNUM <= 20 ) , it is going to infinite.
    Could you please let us know what is the issue with two % used in like and rownum
    5) Modified version of Option1 query (move out the RNUM condition AND RNUM <= 20)
    SELECT * FROM (
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE REFERENCE like '%KMF22600920%' ) WHERE RNUM > 0 AND RNUM <= 20
    Execution Time:- 7.41368914 seconds
    Returns 2 resultsets
    Is the above query is best optimized query which should be used for the Pagination or still can improve on this ?

    This would be easier to diagnose if there was an explain plan posted for the 'good' and 'bad' queries. Generally speaking using '%' on both sides precludes the use of any indexes.

  • Query used by SQL Server Management Pack for monitoring database backups

    I use SCOM 2012 R2 and the SQL Server Management Pack to monitor SQL Server database backups. I believe I am getting false positives. SCOM reports database are not backuped, while in fact they are. So I need to troubleshoot this. I suspect SCOM is querying
    the backup history in the msdb database. I want to know which query SCOM uses.
    I have tried looking in the monitor's definition but I suspect the query is embedded in the management pack files which are binary. I have also tried running a trace using the SQL Server Profiler on my test environment and overriding the interval to 60 seconds,
    but I don't see a relevant query being executed. I also don't see the alert reappear so I suspect SCOM does not honor the interval in a way I would expect.
    What query, or other method, does SCOM use to check database backups?
    Thanks in advance.

    Thank you both Ivan and Michael,
    I only saw your messages by email and didn't see your screen shot before I extracted the query myself. In my own queries I calculate the backup age in hours instead of days because of daily full backups. Perhaps It will be a good idea to create my own monitors
    from scratch like I used to do with Nagios.
    I will study the vbscripts and might create my own version which allows the query to be entered as an parameter and move all code to a .Net class which can be called from vbscript as an COM object. This way I hope to reduce the vbscript code to an minimum
    while keeping the flexibility of the SCOM Operations Console and the robustness of .Net. I suspect I want to make more non standard monitors in the future.
    Regards,
    Arjen

  • Inconsistencies between CR wildcard (* and ?) and SQL std queries (% and _)

    Certain queries built using Crystal Reports do not return a full result set of data as expected, compared to using standard SQL wildcards in an interactive native SQL tool.
    Does anybody know if any of these are bugs in Crystal Reports?
    See example data and queries with their associated results below.
    Example:
    Table name: customer
          Column definitions:
              lname char(20)
              state char(2)
          Relevant rows from our demo database, queried from the native interactive SQL tool are shown below.  For the purposes of illustration, I modified some of the state fields so that there were examples of 'N ', ' N' and 'N' (space in front of the letter N, space after the letter N, and just the letter N with no spaces). I have also added the single quote characters in the query results for those rows to highlight where the spaces exist or do not exist in the data:
    1 > select id,lname,city,state from customer
          where state like '%N%' or lname like '%en %'
    Col.    id      lname                   city                    state
    [ 1]    101     Devlin                  Rutherford              'N ' < was NJ
    [ 2]    102     Reiser                  New York                'N'  < was NY
    [ 3]    104     Mason                   Knoxville               NN
    [ 4]    105     McCarthy                Carmel                  IN
    [ 5]    107     Colburn                 Raleigh                 NC
    [ 6]    108     Goforth                 Chattanooga             ' N' < was TN
    [ 7]    111     Ricci                   Syracuse                NY
    [ 8]    112     McDonough               Brooklyn Park           MN
    [ 9]    113     Kaiser                  Minneapolis             MN
    [ 10]   114     Chopp                   St Paul                 MN
    [ 11]   115     Phillips                St Paul                 MN
    [ 12]   116     Gugliuzza               Mamaroneck              NY
    [ 13]   118     Sanford                 Raleigh                 NC
    [ 14]   120     Stein                   Elmsford                NY
    [ 15]   121     Elkins                  Carmel                  IN
    [ 16]   129     Fahrvergnugen           Baltimore               MD
    [ 17]   131     Sinnot                  Bohemia                 NY
    [ 18]   132     King                    Fort Wayne              IN
    [ 19]   135     Clarke                  New York                NY
    [ 20]   136     Wooten                  Plymouth                MN
    [ 21]   137     Morfek                  Ft. Wayne               IN
    [ 22]   138     Patoff                  Burlington              ON
    [ 23]   141     Pyper                   Fort Wayne              IN
    [ 24]   147     Lela                    Wood Bridge             NJ
    [ 25]   150     Mason                   Don Mills               ON
    [ 26]   152     Jones                   Austin                  NY
    [ 27]   160     Nette                   Port Washington         NY
    [ 28]   163     Peese                   Mississauga             ON
    [ 29]   165     Mournen                 Ft. Wayne               IN
    [ 30]   169     Terlemezian             Matthews                NC
    [ 31]   177     Zubenko                 Raleigh                 NC
    [ 32]   179     Nguyen                  Miramar                 FL
    [ 33]   180     Peros                   Rochester               NY
    [ 34]   181     Teeven                  Washington              DC
    [ 35]   198     Chen                    San Ramon               CA
    [ 36]   199     Mentary                 Rochester               NY
    [ 37]   202     Murphy                  White Plains            NY
    [ 38]   208     Suess                   Albany                  NY
    [ 39]   221     Johnson                 Santa Fe                NM
    [ 40]   331     Johansen                New Orleans             LA
    [ 41]   550     Antolini                Fargo                   ND
    [ 42]   552     OToole                  Nashville               TN
    [ 43]   665     Thompson                Manchester              NY
    43 rows Affected.
    Several queries perform as expected between Crystal Reports and the native SQL query tool.  However, in some cases, the results are different.  Crystal Reports does not return as much data as the native SQL query tool.  I'm not implying which one is correct, I'm merely stating that there is a difference between them.
    In the cases below, the 'Crystal Reports record selection formula' is obtained by navigating the Crystal Reports menu: Report -> Selection Formulas -> Record...
    Single quotes are not specified in the results below - refer above for the actual data in those rows.
    The following cases are inconsistent between the native SQL query tool and Crystal Reports designer:
    Case 1:
    Length of field to be searched: Short (2 chars)
    Wildcard description: letter 'N' + any single character
    Native interactive SQL query and results:
    1 > select id,lname,city,state from customer where state like 'N_'
    Columns:        id      lname   city    state
    [ 1]    101     Devlin                  Rutherford              N
    [ 2]    102     Reiser                  New York                N
    [ 3]    104     Mason                   Knoxville               NN
    [ 4]    107     Colburn                 Raleigh                 NC
    [ 5]    111     Ricci                   Syracuse                NY
    [ 6]    116     Gugliuzza               Mamaroneck              NY
    [ 7]    118     Sanford                 Raleigh                 NC
    [ 8]    120     Stein                   Elmsford                NY
    [ 9]    131     Sinnot                  Bohemia                 NY
    [ 10]   135     Clarke                  New York                NY
    [ 11]   147     Lela                    Wood Bridge             NJ
    [ 12]   152     Jones                   Austin                  NY
    [ 13]   160     Nette                   Port Washington         NY
    [ 14]   169     Terlemezian             Matthews                NC
    [ 15]   177     Zubenko                 Raleigh                 NC
    [ 16]   180     Peros                   Rochester               NY
    [ 17]   199     Mentary                 Rochester               NY
    [ 18]   202     Murphy                  White Plains            NY
    [ 19]   208     Suess                   Albany                  NY
    [ 20]   221     Johnson                 Santa Fe                NM
    [ 21]   550     Antolini                Fargo                   ND
    [ 22]   665     Thompson                Manchester              NY
    22 rows Affected.
    Crystal Reports record selection formula and results:
    {customer.state} like "N?"
                            id  lname                 city                  state
                           104  Mason                 Knoxville             NN
                           107  Colburn               Raleigh               NC
                           111  Ricci                 Syracuse              NY
                           116  Gugliuzza             Mamaroneck            NY
                           118  Sanford               Raleigh               NC
                           120  Stein                 Elmsford              NY
                           131  Sinnot                Bohemia               NY
                           135  Clarke                New York              NY
                           147  Lela                  Wood Bridge           NJ
                           152  Jones                 Austin                NY
                           160  Nette                 Port Washington       NY
                           169  Terlemezian           Matthews              NC
                           177  Zubenko               Raleigh               NC
                           180  Peros                 Rochester             NY
                           199  Mentary               Rochester             NY
                           202  Murphy                White Plains          NY
                           208  Suess                 Albany                NY
                           221  Johnson               Santa Fe              NM
                           550  Antolini              Fargo                 ND
                           665  Thompson              Manchester            NY
    Note that the first two rows are not present here.
    Case 2:
    Length of field to be searched: Short (2 chars)
    Wildcard description: letter 'N' + one space 
    Native interactive SQL query and results:
    1 > select id,lname,city,state from customer where state like 'N '
    Columns:        id      lname   city    state
    [ 1]    101     Devlin                  Rutherford              N
    [ 2]    102     Reiser                  New York                N
    2 rows Affected.
    Crystal Reports record selection formula (menu: Report -> Selection Formulas -> Record...) and results:
    {customer.state} like "N "
                            id  lname                 city                  state
    No data is displayed.
    Case 3:
    Length of field to be searched: Long (20 chars)
    Wildcard description: 0 or more + 'en' + space + 0 or more
    Native interactive SQL query and results:
    1 > select id,lname,city,state from customer where lname like '%en %'
    Columns:        id      lname   city    state
    [ 1]    129     Fahrvergnugen           Baltimore               MD
    [ 2]    136     Wooten                  Plymouth                MN
    [ 3]    165     Mournen                 Ft. Wayne               IN
    [ 4]    179     Nguyen                  Miramar                 FL
    [ 5]    181     Teeven                  Washington              DC
    [ 6]    198     Chen                    San Ramon               CA
    [ 7]    331     Johansen                New Orleans             LA
    7 rows Affected.
    Crystal Reports record selection formula (menu: Report -> Selection Formulas -> Record...) and results:
    {customer.lname} like "*en *"
                            id  lname                 city                  state
    No data is displayed.
    Case 4:
    Length of field to be searched: Long (20 chars)
    Wildcard description: 0 or more + 'en' + any 7 chars
    Native interactive SQL query and results:
    1 > select id,lname,city,state from customer where lname like '%en_______'
    Columns:        id      lname   city    state
    [ 1]    129     Fahrvergnugen           Baltimore               MD
    1 rows Affected.
    Crystal Reports record selection formula (menu: Report -> Selection Formulas -> Record...) and results:
    {customer.lname} like "*en???????"
                            id  lname                 city                  state
    No data is displayed.
    Case 5:
    Length of field to be searched: Long (20 chars)
    Wildcard description: 0 or more + 'en' + seven spaces
    Native interactive SQL query and results:
    1 > select id,lname,city,state from customer where lname like '%en       '
    Columns:        id      lname   city    state
    [ 1]    129     Fahrvergnugen           Baltimore               MD
    1 rows Affected.
    Crystal Reports record selection formula (menu: Report -> Selection Formulas -> Record...) and results:
    {customer.lname} like "*en       "
                            id  lname                 city                  state
    No data is displayed.

    Clint,
    Yes, I think that would probably work fine. 
    The point here is that I think there is a bug in the way Crystal Reports processes wild card strings and passes the sql to the downstream database.  Crystal Reports should translate the wild card strings into the corresponding sql standard syntax, and pass the wild card string to the database, but it does not appear to be doing this.
    At this point, I am only interested in notifying the SAP / Business Objects engineering department of this bug, or in posts that point me to a fix to the bug, rather than a work-around.
    Thanks . . .
    - Jay

  • Search in txt file using PL/SQL

    Is there any way to search for a string in a text file using a PL/SQL block??
    Thnks in advance.
    Ashish

    Richard:
    It would depend on the nature of the text file, but it could be done for most plain text files. If there is some consistent delimiter, that is, the text file is fielded in some way, you could define an external table with the appropriate structure then use normal SQL queries against the particular fields from the file.
    If the file is just plain text with no fields, you could create an external table something like:
    CREATE TABLE myexternal (
       line VARCHAR2(4000),
    ORGANIZATION EXTERNAL
    (TYPE oracle_loader
    DEFAULT DIRECTORY mydirectory
    ACCESS PARAMETERS
    (RECORDS DELIMITED BY newline
      BADFILE 'textfile.bad'
      DISCARDFILE 'textfile.dis'
      LOGFILE 'textfile.log'
      (line CHAR(4000) NULLIF line = blanks))
        LOCATION ('textfile.txt'))
    REJECT LIMIT UNLIMITEDThen use normal sql to search the contents of that file.
    I have not done any benchmarks on this, but my gut feel is that it would be significantly faster than using utl_file to loop over the lines looking for specific content.
    In one of our warehouse load programs, we process a text file that is typically about 7Mb in under 30 seconds.
    John

  • How I can create dynamically-formed requests or use native SQL in EJB?

    Hi all.
    I'm working around modify an example from NetWeaver Developer Studio (CarRental). I want to get ordered data from table and allow users to specify the ordering field, not in the code. EJB QL doesn't support dynamically-formed queries like "select object(b) from QuickBooking b where b.status like ?1 order by b.<b>?2</b>" so i can't passing field name as parameter into query. Creating a sorting method for every field is not good solution because I need a dynamically-formed requests.
    I think using native SQL will help but I don't know how I can use SQL in EJB.
    Thanks,
    Lev

    import javax.persistence.EntityManager;within class, place
    protected EntityManager  entityManager;of course make it public, private, whatever you need.
    Then, in your method
    entityManager.createNativeQuery(....);R. Grimes

  • Parameter list in SQL native queries

    I need to migrate from Toplink 10 to EclipseLink.
    In my "old" project, I have some SQL native queries like '...... where field in #pFieldValues'
    #pFieldValues is an arraylist/vector.
    It was working perfectly with TopLink 10, but now it fails with 'Oracle Error' 'Invalid column type'.
    How can I achieve this now with EclipseLink?  (I don't want to use EJBQL queries (or JPQL queries).
    Thanks

    I made it work modifying SQL statement for Access database by passing parametres in where clause.
    But it works only for single value , though I have checked Allow multiple values: true. but fails when passing more than one value,
    Error message pops up " Failed to retrive data from database. The Microsoft Access database engine could not find the object tblHirarchy('ANSTG', 'MCIS')
    How to resolve it?
    SELECT tbl_CBP.forcast_in_MON, tbl_CBP.forcast_MON, tbl_CBP.forcast_QTR,
    tbl_Hierarchy.Technology_Group, tbl_Hierarchy.[Business_ Unit],
    tbl_Hierarchy.Product_Family, tbl_CBP.Units, tbl_CBP.Cost, tbl_CBP.REV,
    tbl_Time.Sort_order
    FROM (tbl_Hierarchy INNER JOIN tbl_CBP ON tbl_Hierarchy.Product_Family =
    tbl_CBP.PF) INNER JOIN tbl_Time ON tbl_CBP.forcast_MON =
    tbl_Time.Fiscal_Month
    where tbl_Hierarchy.Technology_Group = {?TG}
    ORDER BY [sort_order]
    union all
    SELECT [Forcast_In_MON] & ' Actuals' AS forcast_In, tbl_Time.Fiscal_Month,
    tbl_Time.Fiscal_Quarter, tbl_Hierarchy.Technology_Group, tbl_Hierarchy.
    [Business_ Unit], tbl_Hierarchy.Product_Family, tbl_Actuals.Units,
    tbl_Actuals.Cost, tbl_Actuals.REV, tbl_Time.Sort_order
    FROM (tbl_Actuals INNER JOIN tbl_Hierarchy ON tbl_Actuals.PF =
    tbl_Hierarchy.Product_Family) INNER JOIN tbl_Time ON tbl_Actuals.Actuals_MON
    = tbl_Time.Forcast_In_MON
    where tbl_Hierarchy.Technology_Group = {?TG}
    ORDER BY [sort_order];
    your HELP is highly appreciated.

  • Export to csv gone in SQL Server queries in 2.1

    In 1.5 I could save the output from SQL Server queries to a CSV or XLS file.
    The entire option is now gone.
    This is very important to our organization

    Based on Re: How export result in sybase in SQL Developer 2.1 ? and Re: SQL Developer 2.1.0.63 - Export Data menu missing for SQL Server databases it looks like this was intentionally removed (for some reason not given) and will not be back in the short term (or longer, depending on what Barry meant by "this release" back in the time of 2.1's release candidate version). Short of using something like "select all in the results tab, copy, paste into Excel, save as CSV" (relatively painful and subject to Excel interpreting text as numbers or dates instead of text), the simplest would probably be to revert to 1.5.
    theFurryOne

  • SQLEception using Complex SQL Query with Java Studio Creator2 Build(060120)

    I am evaluating Java Studio Creator2 for a WEB base application project that will be making SQL queries to an Oracle Database but I have stumble into a problem using complex SQL queries.
    I am getting an SQLException "org.apache.jasper.JasperException: java.lang.RuntimeException: java.sql.SQLException: [sunm][Oracle JDBC Driver][Oracle]ORA-00923: FROM keyword not found where expected". I looks like it cut my sql.
    The SQL that I am trying to execute is
    Select part_name
    from table1, table2
    where table1.part_nbr = table2.part_nbr
    and table2.row_add_dt = (select max(table3.row_add_dt)
    from table3
    where table3.ser_part_id =table2.ser_part_id)
    This is a valid query that it is using 2 different selects to get a part number.
    If posible, point me to the best solution were I will be able to make complex SQL queries like the one above and bigger.
    Is there any way that I can read an SQL query file instead of inserting the SQL query string into the setCommand()?

    I have read that document looking for some anwsers on how to make this kind of query. If I try the query that I have above in the query editor ,the query editor will cut off from the last select that is between ().
    I beleave, there is a work around using the inner joint or outter join command. I will try them to see If I get the corrent result. If not, then I have to keep on asking for possible solutions.
    Anyway, someone in the Creator Team should take a note in adding something like a special criteria in the Add Query Criteria Box for cases like the one I have. The special criteria will be like using another select/from/where to get some result that will be compare.
    Girish, Are you in the Sun Creator Team?

  • Nube here: trying to copy a db from 1 comp to 2nd using Oracle SQL dev

    Hi, nube here. I am trying to copy SQL database established locally on my laptop and copy it to my desktop pc so i can practice running queries on there. I have tried to migrate and i failed. i have the password for the schema created on my laptop.
    now am i trying to create a new schema on my desktop? or do i copy the schema also? i am also unable to pass the "test connection" when i create any new schema on my desktop.i share the same home network. these are merely just practice databases so i can practice on my desktop as well as my laptop. And what do you mean on the same domain? do you mean create exact same schema on my desktop? and am i using RMAN to backup and restore? or what tool because google says its not possible to back up and recover viz oracle sql developer.
    I am using orcle sql developer verison 1.5.3 on my laptop and ver 3.2.20.09 on my desktop.
    please help

    Hi Nube,
    Update to 3.2.20.09 on your laptop.
    For between non Oracle databases and Oracle:
    There is right click on a table "Copy To Oracle".
    Migration getting started:
    http://www.oracle.com/technetwork/database/migration/omwb-getstarted-093461.html
    [for between Oracle databases there is a Data Pump wizard in the DBA view,
    also database copy, or even copy command in the worksheet,
    you could use RMAN for duplicating databases (or OS commands like copy(Windows)/cp(Unix/Linux) when the database is brought down with "shutdown immediate")
    RMAN and OS commards are outside the scope of the SQLDeveloper forum]
    i am also unable to pass the "test connection"Not sure what database you are connecting to
    - you need to get port/host and the equivalent of service right
    - firewall rules need to be set up if appropriate.
    - also the database server needs to be listening on that port.
    -Turloch
    SQLDeveloper Team

  • How can i use one SQL statement to solve problem?

    How can i use one SQL statement to solve the question below?
    For a Table named A, there is a column named F(char type).
    Now select all the records where F like '%00' and update their F value to '%01'
    Just one SQL statement.Do not use PL/SQL block.
    How to do that?
    Thanks.

    What is the data volume for this table?
    Do you expect lots of rows to have '%00' as their value?
    Following two statements come to mind. Other experts would be able to provide better alternatives:
    If you have index on SUBSTR(f, 2):
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) || '01'
    WHERE  substr(f,
                  -2) = '00';If most of the rows have pattern '%00':
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) ||
               DECODE(SUBSTR(f,
                             -2),
                      '00',
                      '01',
                      SUBSTR(f,
                             -2));

Maybe you are looking for