Groups | Blog | Home
all groups > asp.net > april 2006 >

asp.net : [ ] (Wildcard - Character(s) to Match) ?


Bruce Lawson
4/18/2006 10:35:56 PM
Hi, I am confused about Microsofts description of this Transact SQL
reference; [] (Wildcard - Character(s) to Match. The description says
"Matches any single character within the specified range or set that is
specified inside the square brackets". For example, in the TransactSQL
statement "UPDATE tblUsers SET [Password] = stringUserPassword WHERE UserId
= 2" , what do the brackets signify about the database record in column
Password being updated? TYIA
BruceL


Karl Seguin [MVP]
4/19/2006 7:48:53 AM
The [] have two meanings. The one you described is only applicable inside a
string with the LIKE operator...ala:

select blah from blahTable where description like '[ab]oat'

which doesn't really make sense, but you get the idea..

outside of this case, [] is used to escape reserved keyword names. Password
is actually a reserved word in TSQL, so the only way you can safely use it
as a column/table/sproc name it to wrap it in []. You can often omit the []
for reserved words, and TSQL will figure out what you mean, but I'd advise
against it.

If you type a query and a column name/table turns blue (or whatever color
your SQL syntax turns, like the word SELECT or FROM) than you should put it
in [] :)

Karl

--
http://www.openmymind.net/



[quoted text, click to view]

AddThis Social Bookmark Button