Rated
Read 59,237 times
Related Categories
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.
James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.
Comments
-
Posted by takas20 on 09 Nov 2007
customer ids beginning with "C10" (can have any number of characters or no characters at all)
17 found from select * from booking where [customer id num] like 'C10*'
customer ids beginn...
-
i believe examples of the usage of these wildcards should be given in more real-life applications
:o
|