SQL Server wild card operator determine whether the string matches a specified pattern. There four SQL server wild card operators "%","_","" and "[^]".
Lets understand each one of them. For example conside the below sample of data
If you use "s%" in your query as shown below. It will list all words starting with character "s" followed by zero or more any characters.
select * from tblWords where Words like 's%'
If you use the below query with "s_t" , it will find exactly any one character between letters "s" and "t". You can see he has omitted "Salt" and "Salty" as it two letter "al" in between.
select * from tblWords where Words like 's_t'
if you use "[al]" in your select search it will find all words which has "al" in between them.
select * from tblWords where Words like 's[al]%'
If you use "[^]" it will be display words which do not have "al" in the word.
select * from tblWords where Words like 's[^al]%'
View following video on SQL Server interview questions on normalization and denormalization.
See for more stuff on SQL Server Interview question
Click to view more from author's on SQL Server Interview question
write a comment