 Hello guys welcome back my name is Susheel Singh and this is continuation of SQL Server interview questions and answers. So today I am going to discuss about the like operator. So what is like operator? Like operator is used in ware clause to search for a specified pattern by using wildcards and mostly we use two type of wildcards in like operator one is percentage another is underscore. This is used for 0 to any character and underscore is used for a exact one character and we will discuss later in this video session. Now let's start. So this is our first slide where we have specify few questions. Our first question is get those records which name start with A. So let's move to SQL Server Managed Studio. I have created this table and we have five record on this table. And we want only those records which you know student name is start with A. So by using like operator we will get the result. In this query we can see we have used percentile. As I have discussed percentile is used for 0 to any character. So starting value should be A and end with any character. So in this table we can see we have only one row for this condition. So by using this query we will get only one row. So this is our first question. And our second question is get those record which name end with Z. So for this we can see start with A and now we are going to get the result which name end with Z. So this time percentile will use for the first and then we use the Z as a last character. So we can select and we will get the result. And our third question is get those records which name start with A and end with Z. So here we can see we have used A and then percentile and then Z. So it may be any character between A and Z. But starting value of this S name should be A and end with Z. So by using this query we will get the result. So this is our first slide. Let's move to second. Our next question is get those records which name second position is B. As I have discussed underscore is used for the single character. So in this query we can see inside the like operator we have used the underscore for the first position. So it might be any character. So first character would be skipped. First character has been skipped from there and the second position is B. So we have to specify B from there and then percentile. So by using this query we will get the result. Let's move to sequence of manual studio and execute this query. So this is our query. We can execute and get the result. So our next question is get those records which name contains CD at any position. But CDs would come together first come C and then D. So it might be it would come first position second position at any position. So we have to use the percentile at the starting and end and inside the percentile we have to use the CD. So by using this query we will get the result. Another question is get those records which name start with A and contains at least three characters. So as I have discussed underscore is used for the single character. So here we have to use at least two underscores for the two characters and one character would be count from A. In this query we can see a name like A for the starting position and then we have to specify the underscore and one more underscore and inside the underscores we have to specify percentile. It might be any character between you know underscores or A. So when we are going to execute this query we can see we will get the result. Let's move to another question. This is get those records which name start with A or M or F. Then we are going to such type of conditions where it would contain one or more than one characters at the starting position. So we have to specify the square bracket and inside the square bracket we have to specify all those characters which may be at the starting position. So this is our query and we can execute and we will get the result. Here we can see A or M or F starting position should be A or M or F. So inside the square bracket we have to specify all these three characters. So we can see our output. Another question is get those records which name doesn't start with A or M or F. So we have two queries to get the similar result. First we have to use the above query for the same and except we are using like we have to use the not like. Here we execute and we will get the result. Our second question is we have to use this operator. I don't know the name of this operator. So we have to specify this operator before we are going to specify our characters and then execute and we will get the same result. So we can execute these two queries at once and we will see it would return two rows for the first query and two rows for the second query. So output would be same. Our next question is get those records which name start with A and you know start with between A and M. So it might be A, B, C, D it may be anything but it would be between A to M. When we are going to get such type of condition. So we can specify A, B, C, D, F, G, H up to M inside this square bracket. But this is not the proper way. So we can see we have used dash inside the square bracket and between A to M. When we are going to specify this dash it will act as a between operator. So we execute this query and we can see we will get the result. Now let's move to another question. So another question is get those records which name contains the percentile. As I have discussed percentile is used for the zero to any character. But we want those values which name would contain percentile like let's move to sequence of management studio and here we can see in this we have student id 6 and value is s name is x, y, x and then percentile and dt. So write the query which will return such type of conditions. So here we have to use the square bracket and inside the square bracket we can use we can pass the percentile and it will reflect the result. So for the same if we are we are going to get the result which will contain the underscore we will use the same query and we will get the result. After we need to insert some value so we can insert and then we can select and we can see here it will reflect the result. So I hope you have enjoyed this video. If you like this video please subscribe our channel for many more videos. If you need this script it will all level on my Facebook page you can go through over there and copy from there. Thank you so much for watching this.