exec sp_executesql

        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 });

exec sp_executesql 
N' 
select * from T_User_YFCulture where  1=1 
and Major = ''集态'' 
and Deleted = 0 and Minor = @p1',
N' @p1 nvarchar(4000)',
@p1 = N'1001001'

 

posted @ 2019-12-25 13:55  enych  阅读(521)  评论(0编辑  收藏  举报