首页 > 代码库 > SQL Server参数化查询中应用Like

SQL Server参数化查询中应用Like

一般情况下是SQL语句:

Select * From Users Where UserName Like ‘Lin%‘

Select * From Users Where UserName Like ‘Lin%‘

 

采用参数化SQL

DECLARE @pattern VARCHAR(MAX)SET @pattern=Lin%‘Select * From Users Where UserName Like @pattern