exec sp_executesql
exec sp_executesql N'select * from T_TableName where p_name like @Name order by p_id',N'@Name nvarchar(20)',@Name=N'%测试%'
like 语句
exec sp_executesql
N' SELECT Id,DictEncode,PEncode,DictValue,Sort,Remark,IsDel,CreateUserName,CreateRealName,CreateTime,ModifyUserName,ModifyRealName,ModifyTime FROM T_DictInfo where 1 = 1
AND DictValue LIKE @PEncode AND IsDel=@IsDel ;',
N' @PEncode nvarchar(4000),
@IsDel bit ',
@PEncode = N'%典%'
, @IsDel = 0
转自 https://blog.csdn.net/winnyrain/article/details/70236896
exec sp_executesql
N' SELECT Id,DictEncode,PEncode,DictValue,Sort,Remark,IsDel,CreateUserName,CreateRealName,CreateTime,ModifyUserName,ModifyRealName,ModifyTime FROM T_DictInfo where 1 = 1
AND CreateTime BETWEEN @begin AND @end ;',
N' @begin nvarchar(4000), @end nvarchar(4000) ',
@begin = N'2010-01-01',
@end = N'2020-01-01'
List<parameter> list = new List<parameter>();
list.Add(new parameter { key = "PEncode", val = "%0%", type = 2 });
list.Add(new parameter { key = "IsDel", val = false });
list.Add(new parameter { key = "CreateTime", val = new { begin = "2010", end = "2019" }, type = 3 });