SQL wildcard
What is SQL wildcard?I am not familiar with it.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Nov 22, 2011, 1:15 AM
Please refer our recommended article
Wildcards in SQL Server 2005
http://www.c-sharpcorner.com/uploadfile/karthikarajamma/wildcards-in-sql-server-2005/default.aspx
Thanks
Priya LingePosted Nov 22, 2011, 12:46 AM
1.SQL wildcards can be used when searching for data in a database.
2.SQL wildcards can substitute for one or more characters when searching for data in a database.
SQL wildcards must be used with the SQL LIKE operator.
WildCard
% : A substitute for zero or more characters
_ : A substitute for exactly one character
[charlist] :Any single character in charlist
[^charlist]
or :Any single character not in charlist
[!charlist]
3.Example :
we want to select the persons living in a city that starts with "sa" from the "Persons" table.
SELECT * FROM Persons WHERE City LIKE 'sa%'
we want to select the persons living in a city that contains the pattern "nes" from the "Persons" table.
SELECT * FROM Persons WHERE City LIKE '%nes%'
we want to select the persons with a first name that starts with any character, followed by "la" from the "Persons" table.
SELECT * FROM Persons
WHERE FirstName LIKE '_la'
For more information please check below link,
http://www.w3schools.com/sql/sql_wildcards.asp
http://www.roseindia.net/sql/SQL_Wildcards.shtml
Hope this will help you.
Thanks.