^ : T-SQL

  • Comments posted to this topic are about the item ^ : T-SQL

  • This was easy one. You can find more about wildcard use with LIKE search condition at below mentioned link:

    http://bhaveshgpatel.wordpress.com/2009/10/03/sql-server-select-statement-with-where-like-clause/



    [font="System"]Bhavesh Patel[/font]

    http://bhaveshgpatel.wordpress.com/
  • There are no start and end for that regular expression na... so the answer should be three..???

  • I took the approach that the answer was easy. Not a wise approach. Good subject.

    Jamie

  • I got tripped up on the fact that the string didn't end with %. So I answered the question for 'Jo[^n]%' instead of 'Jo[^n]'. Oops.

    -----
    a haiku...

    NULL is not zero
    NULL is not an empty string
    NULL is the unknown

  • I answered correctly but didn't get the point, the answer page tells me that the correct selection is '1' because 'Joe' is the only match (which is the fourth selection when I look at the list)

  • daniel.gardiner (11/20/2009)


    I answered correctly but didn't get the point, the answer page tells me that the correct selection is '1' because 'Joe' is the only match (which is the fourth selection when I look at the list)

    The query is pulling a count of matches, not the id value.

    -----
    a haiku...

    NULL is not zero
    NULL is not an empty string
    NULL is the unknown

  • ronmoses (11/20/2009)


    daniel.gardiner (11/20/2009)


    I answered correctly but didn't get the point, the answer page tells me that the correct selection is '1' because 'Joe' is the only match (which is the fourth selection when I look at the list)

    The query is pulling a count of matches, not the id value.

    D'oh! Focused on the regex and not enough on the sql.

  • ronmoses (11/20/2009)


    I got tripped up on the fact that the string didn't end with %. So I answered the question for 'Jo[^n]%' instead of 'Jo[^n]'. Oops.

    Thank you ron, I did the same thing, but got confused for a second and thought that I had been using this incorrectly the entire time, and that the brackets were somehow referring to any character, not just the third. Your response clarified it for me.

    Good simple question, keeping us in the details. 😀

    ---------------------------------------------------------
    How best to post your question[/url]
    How to post performance problems[/url]
    Tally Table:What it is and how it replaces a loop[/url]

    "stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."

  • ronmoses (11/20/2009)


    I got tripped up on the fact that the string didn't end with %. So I answered the question for 'Jo[^n]%' instead of 'Jo[^n]'. Oops.

    Same mistake here...

  • does this change from SQL2000 to SQL2005/8? when i try this in my SQL2000 if i leave the % out of the select- i get zero rows. needless to say when I try the test question in my database only the ones that have an 'n' in the third position are dropped so the answer appears to be three. and according the MSDN site it says:

    The following example uses the [^] operator to find all the people in the Contact table who have first names that start with Al and have a third letter that is not the letter a.

    Copy Code USE AdventureWorks;

    GO

    SELECT FirstName, LastName

    FROM Person.Contact

    WHERE FirstName LIKE 'Al[^a]%'

    ORDER BY FirstName;

    not trying to be difficult- trying to understand what i am missing.. thanks

  • Now is that confirmed....

    May i know what the answer is...???

    If it is 3.... then atleast say thanks na.... 🙂

  • Good question; I had forgotten about all of the pattern matching built into LIKE. I'll have to try to use it more.

  • I almost slected 4 (Joe's ID) then I noticed the * and realized there was only one column in the answer. I had to go back and read the SQL again to catch the count() function. I have learned to think twice about my answers to these questions.

    Good question.

  • rajaneeshk (11/20/2009)


    Now is that confirmed....

    May i know what the answer is...???

    If it is 3.... then atleast say thanks na.... 🙂

    The answer is 1 - there is only one record which matches the LIKE clause.

Viewing 15 posts - 1 through 15 (of 21 total)

You must be logged in to reply to this topic. Login to reply