Transact-SQL Search for Specified Pattern in Column - Like Operator Examples


Tool : Microsoft SQL Server Management Studio (SSMS)

Transact-SQL Create Database And Create Table Examples

Transact-SQL Insert Data Into Table Examples

Transact-SQL Retrieve Data From A Table Examples

Retrieve The Data Whose Column [FirstName] Starts from 'A'

/* Retrieve the data whose column [FirstName] starts from 'A' from the table [Employees] */

Use [SampleDB]
Go
Select * From [Employees]
Where FirstName Like 'A%'


Retrieve The Data Whose Column [FirstName] Ends with 'y'

/* Retrieve the data whose column [FirstName] ends with 'y' from the table [Employees] */

Use [SampleDB]
Go
Select * From [Employees]
Where FirstName Like '%y'


Retrieve The Data Whose Column [FirstName] Contains 'an'

/* Retrieve the data whose column [FirstName] contains 'an' from the table [Employees] */

Use [SampleDB]
Go
Select * From [Employees]
Where FirstName Like '%an%'


張貼留言

0 留言