SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Wildcard


Wildcard

Author
Message
bitbucket-25253
bitbucket-25253
SSCertifiable
SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)

Group: General Forum Members
Points: 7821 Visits: 25280
Removed

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
jshailendra
jshailendra
SSC-Addicted
SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)

Group: General Forum Members
Points: 452 Visits: 455
Gr8 QotD, Thanks...I got it correct...but it was just a calculated guess...as other options were incorrect...
look fwd to use this wildcard...
Bhavesh_Patel
Bhavesh_Patel
Say Hey Kid
Say Hey Kid (679 reputation)Say Hey Kid (679 reputation)Say Hey Kid (679 reputation)Say Hey Kid (679 reputation)Say Hey Kid (679 reputation)Say Hey Kid (679 reputation)Say Hey Kid (679 reputation)Say Hey Kid (679 reputation)

Group: General Forum Members
Points: 679 Visits: 297
Good Question ... had to revise all wildcard characters. :-D



Bhavesh Patel

http://bhaveshgpatel.wordpress.com/
sknox
sknox
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2604 Visits: 2830
To be strict, the source data was a red herring. A where clause shouldn't be based on the data you have, but the data you want.

In this case, for example, it doesn't matter that "Jim" exists in the source data (or "Tim" or "Kim" or "Bim" for that matter). What matters is that you want to retrieve only rows with "Tim" or "Kim".

If you used "Like '%im'", and "Jim" wasn't in the source data, your query would work. Once. But it would break as soon as someone added any other name like '%im'. If you get in the habit of using shortcuts rather than framing your query properly, you'll be rewriting queries more and more often.

Trust me, I know.
sqlusers
sqlusers
Old Hand
Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)

Group: General Forum Members
Points: 307 Visits: 512
Its good to learn something like this Smile

Thanks
TomThomson
TomThomson
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14302 Visits: 12197
sknox (2/1/2010)
To be strict, the source data was a red herring. A where clause shouldn't be based on the data you have, but the data you want.

In this case, for example, it doesn't matter that "Jim" exists in the source data (or "Tim" or "Kim" or "Bim" for that matter). What matters is that you want to retrieve only rows with "Tim" or "Kim".

If you used "Like '%im'", and "Jim" wasn't in the source data, your query would work. Once. But it would break as soon as someone added any other name like '%im'. If you get in the habit of using shortcuts rather than framing your query properly, you'll be rewriting queries more and more often.

Trust me, I know.

Yes, I agree. Now if one of the answers offered had been [^J]im I wonder if anyone would haven fallen into the trap of giving an answer that would work with the given data but not in general - then the source data would have been a real red herring!
It was a good question and answer, anyway.

Tom

Peter Trast
Peter Trast
Say Hey Kid
Say Hey Kid (692 reputation)Say Hey Kid (692 reputation)Say Hey Kid (692 reputation)Say Hey Kid (692 reputation)Say Hey Kid (692 reputation)Say Hey Kid (692 reputation)Say Hey Kid (692 reputation)Say Hey Kid (692 reputation)

Group: General Forum Members
Points: 692 Visits: 655
Thanks for asking one I know without having to think about Smile

Peter Trast
Microsoft Certified ...(insert many literal strings here)
Microsoft Design Architect with Alexander Open Systems
Paul White
Paul White
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15700 Visits: 11355
Nice easy one - thanks :-)



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search