Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

SQL Server Get Data between Two Characters Range Start with A to C

Feb 2, 2014
Introduction:

Here I will explain how to get data between two characters range in
SQL server or get user details start with A-C range in SQL server.

Description:

In previous articles I explained Acid Properties in SQL Server, Query to get database size in SQL Server, show time difference in minute ago hour ago etc in SQL Server, can function return multiple values in SQL Server and many articles relating to SQL server. Now I will explain how to get data between two characters range in SQL server.

I have a requirement like need to get user details whose names between A – C range in SQL server for that I written query like as shown below



SELECT * FROM UserDetails WHERE Name LIKE '[A-C]%'

Whenever we run above query it will return all user details which are in between [A-C] range

Example

Initially my user details table is like this

Now from table I need to get user details who belongs in between [A-C] range for that we need to write the code like as shown below


SELECT * FROM UserDetails WHERE UserName LIKE '[A-C]%' Order BY UserName
Once we run above query we will get output like as shown below

Output


If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

3 comments :

Anonymous said...

Nice blog....

Anonymous said...

Valuable Code...Thanks

Abhijeet said...

Ni article.
Did some more combinations and found that the where clause LIKE '[A%M]%' will return the searched column ONLY if it has values starting with "A" or "M"

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.