34,590
社区成员
发帖
与我相关
我的任务
分享
ALTER PROCEDURE ZYDA__selectRecordByRecordID
@records nvarchar(200),
@type int,
@power int,
@department int,
@id int
as
declare @sql nvarchar(4000)
set @sql='SELECT ZYDA_Records.id, ZYDA_Records.records_no, ZYDA_Records.superscription, ZYDA_Records.mulu,
ZYDA_Records.remark, ZYDA_Records.quanzong,ZYDA_Records.type,ZYDA_FileType.type
FROM ZYDA_Records INNER JOIN
ZYDA_FileType ON ZYDA_Records.type = ZYDA_FileType.id where (1=1) '
-- 如果只有类型 没有案卷 仅搜索类型
if( @type <> '0')
set @sql=@sql+' and ( ZYDA_Records.type like ''%'+@type+'%'')'
like''%'+@records+'%'')'
exec(@sql)
alter PROCEDURE ZYDA__selectRecordByRecordID
@records nvarchar(200),
@type int,
@power int,
@department int,
@id int
as
declare @sql nvarchar(4000)
set @sql='SELECT ZYDA_Records.id, ZYDA_Records.records_no, ZYDA_Records.superscription, ZYDA_Records.mulu,
ZYDA_Records.remark, ZYDA_Records.quanzong,ZYDA_Records.type,ZYDA_FileType.type
FROM ZYDA_Records INNER JOIN
ZYDA_FileType ON ZYDA_Records.type = ZYDA_FileType.id where (1=1) '
-- 如果只有类型 没有案卷 仅搜索类型
if( @type <> '0')
set @sql=@sql+' and ( ZYDA_Records.type like ''%'+Rtrim(@type)++'%'')'
--records like''%'+@records+'%'')'
print (@sql)
exec ZYDA__selectRecordByRecordID '0',1,2,3,4
---试
SELECT ZYDA_Records.id, ZYDA_Records.records_no, ZYDA_Records.superscription, ZYDA_Records.mulu,
ZYDA_Records.remark, ZYDA_Records.quanzong,ZYDA_Records.type,ZYDA_FileType.type
FROM ZYDA_Records INNER JOIN
ZYDA_FileType ON ZYDA_Records.type = ZYDA_FileType.id where (1=1) and ( ZYDA_Records.type like '%1%')
if( @type <> '0')
这里的'0'不改没关系 系统自动转换的
declare @n int
set @n=19
if(@n='19')
select 8
/*
8
*/
like''%'+@records+'%'')'
这个事多余的么?
exec(@sql)
pint(@sql)