In this article, we are going to use the following table for the examples:-
CREATE TABLE [dbo]. [Employee](
[Empid] [Int] IDENTITY (1, 1) NOT NULL Primary key,
[EmpNumber] [nvarchar](50) NOT NULL,
[EmpFirstName] [nvarchar](150) NOT NULL,
[EmpLAStName] [nvarchar](150) NULL,
[EmpEmail] [nvarchar](150) NULL,
[Salary] [int] NULL
)
We insert following data into the above tables:-
Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A001′,’Vivek’,’Johari’,’samir@abcmail.com’,200000)
Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A002′,’Amit’,’Kumar’,’amit@abcmail.com’,100000)
Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A003′,’Neha’,’Sharma’,’neha@abcmail.com’,300000)
Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A004′,’Nidhi’,’Sharma’,’nidhi@abcmail.com’,270000)
For example, suppose we want to get the records of the employee whose firstname start with character ‘N’, then we can use the below query:-
select * from employee where EmpFirstName like ‘N%’
This query will returns the records for the employee whose empnumber is given below:
A003
A004
Again, suppose we want to get the records of the employees whose last name end with character ‘a’, then we can use the below query:-
Select * from employee where EmplastName like ‘%a’
This query will returns the records for the employee whose empnumber is given below:-
A003
A004
Now, suppose we want to get the records of the employees whose last name contains character ‘ha’, then we can use the below query:-
select * from employee where EmplastName like ‘%ha%’
This query will returns the records for the employees whose empnumber is given below:
A001
A003
A004
Discover more from Technology with Vivek Johari
Subscribe to get the latest posts sent to your email.
… [Trackback]
[…] Read More on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] There you will find 23503 more Information on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Read More on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Read More Information here on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Read More here to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Find More here on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Find More on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Information on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Find More Info here on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Info on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Read More Info here to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Read More to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Info on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Find More Information here to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Find More here to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Information on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Find More on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Information to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Information on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Read More Information here to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Read More on to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Find More Info here to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Here you will find 98126 more Information on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Find More to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Read More to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] There you will find 12512 more Information to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] There you can find 29750 more Info on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Read More here to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] There you will find 5486 more Information to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] Find More Info here to that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]
… [Trackback]
[…] There you can find 89661 additional Info on that Topic: techmixing.com/2014/08/like-function-in-sql-server.html […]