Access, VB and SQL Server wildcard characters

Visual Basic gives you several ways to provide pattern-matches in a
search string. Typically, you use pattern-matching characters for two
purposes: to search for strings in a VB application's GUI or variable,
or to look for items within a database, such as Access or SQL. When you
search for pattern matches in a database, however, depending on which
database you're using, different characters perform different matches.

The following list shows the different characters used by each database:

Required Match
Any single character
               Access/VB: ? SQLServer: _
Zero or more characters
               Access/VB: * SQLServer: %
Any single digit (0-9)
               Access/VB: # SQLServer: n/a
Any single character in charlist
               Access/VB: [charlist] SQLServer: [charlist]
Any single character not in charlist
               Access/VB: [!charlist] SQLServer: [^charlist]

Keep in mind that when you use Visual Basic's SQL Builder to create SQL
statements, it only accepts SQL Server pattern-matching characters--even
when you're pulling data from an Access database.

You might also like...


James Crowley James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audience ...


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only 3 numbers of interest to a computer scientist: 1, 0 and infinity”