SQL Substring searches

SQL Substring searches

How do you select all entries that contain a certain substring? Is there a function like InStr() in VB?

Yes, Check out the charindex function which will Return the number of the position the charcter searched for occupies in the searched for expression. Try this in Pubs:

select charindex("B", title_id) from titleauthor--------------------- 111111000000


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist