What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 2383 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > SQL Server > SQL query to select the records where name start with some specific character. ...
Abhisek

SQL query to select the records where name start with some specific character.

 Code Snippet posted by: Abhisek | Posted on: 3/3/2010 | Category: SQL Server Codes | Views: 3920 | Status: [Member] | Alert Moderator   


SELECT name,roll FROM Student WHERE name LIKE 'AB%'


It will display the records in which the name starts with AB.

Abhisek Panda
Found interesting? Add this to:


 Responses

Pandians
Posted by: Pandians | Posted on: 3/1/2010 | Level: Silver | Status: [Member] [MVP] | Alert Moderator 

Hi

Greetings

The query will perform only MAXIMUM 3 Characters in [name] column, not for Morethan THREE characters...

It should be...
SELECT [name],roll FROM Student WHERE [name] LIKE 'AB%'

Please change the query / question

Cheers


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Puneet20884
Posted by: Puneet20884 | Posted on: 3/3/2010 | Level: Bronze | Status: [Member] | Alert Moderator 

You mentioned "It will display the records in which the name starts with AB."

But it will display the records in which the name is AB_.

Please modify your query to
the one suggested by Pandians
as

SELECT [name],roll FROM Student WHERE [name] LIKE 'AB%'

in order to fetch what is mentioned !!

Best Regards,
Puneet Sharma - Infosys
Pune, India

Abhisek
Posted by: Abhisek | Posted on: 3/3/2010 | Level: Bronze | Status: [Member] | Alert Moderator 

Thanks for your correction. It is posted by mistake. Sorry for the mistake.

Abhisek Panda

>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 8:49:35 PM