Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to Identify name starting with a specific letter without using like operator? Expand / Collapse
Author
Message
Posted Friday, October 25, 2013 6:14 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, January 10, 2014 4:43 AM
Points: 15, Visits: 44
Hi All,

How to Identify name starting with a specific letter without using like operator?

Please help me out.

Thanks in advance,
Sharmi
Post #1508428
Posted Friday, October 25, 2013 6:20 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, October 27, 2014 8:18 AM
Points: 2,404, Visits: 2,940
Why do you have the restriction of using the LIKE operator?

But you can accomplish this for example by using the LEFT or the SUBSTRING operator.


** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
Post #1508429
Posted Friday, October 25, 2013 6:47 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 10:43 AM
Points: 6,961, Visits: 7,088
HanShi (10/25/2013)
Why do you have the restriction of using the LIKE operator?

But you can accomplish this for example by using the LEFT or the SUBSTRING operator.


Bear in mind thet LEFT and SUBSTRING will not use any suitable indexes (possible performance issues) whereas LIKE will.



Far away is close at hand in the images of elsewhere.

Anon.

Post #1508439
Posted Friday, October 25, 2013 6:48 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Saturday, October 25, 2014 11:42 AM
Points: 2,380, Visits: 7,591
Could do something odd like this: -

WHERE Names = STUFF(Names,1,1,'A')

That'd tell you if the "Names" started with an A.



Not a DBA, just trying to learn

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better, quicker answers on SQL Server performance related questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/



If you litter your database queries with nolock query hints, are you aware of the side effects?
Try reading a few of these links...

(*) Missing rows with nolock
(*) Allocation order scans with nolock
(*) Consistency issues with nolock
(*) Transient Corruption Errors in SQL Server error log caused by nolock
(*) Dirty reads, read errors, reading rows twice and missing rows with nolock


LinkedIn | Blog coming soon (for sufficiently large values of "soon" )!
Post #1508441
Posted Friday, October 25, 2013 6:53 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 6:05 AM
Points: 40,258, Visits: 36,681
sharmili.net (10/25/2013)
Hi All,

How to Identify name starting with a specific letter without using like operator?

Please help me out.


Why? That's what the LIKE operator is there for, refusing to use the tool most suitable to the problem is strange.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1508442
Posted Friday, October 25, 2013 10:26 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:02 PM
Points: 35,397, Visits: 31,955
sharmili.net (10/25/2013)
Hi All,

How to Identify name starting with a specific letter without using like operator?

Please help me out.

Thanks in advance,
Sharmi


It depends... how slow do you want the code to actually run?

I join Gail in asking, why would anyone want to do such a thing? The courtesy of a reply would be much appreciated.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1508524
Posted Friday, October 25, 2013 11:39 AM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 1:03 PM
Points: 4,279, Visits: 3,719
It sounds like a homework question to me. The lesson would be that, aside from the obvious approach, there's more than one way to accomplish something. In this case, hopefully eliminating the efficient solution will also be covered in the lesson.


Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Post #1508551
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse