调了一小时了 不知道哪错了。。。。

sheixiu sheixiu 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区




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)

显示错误:
正在运行 [dbo].[ZYDA__selectRecordByRecordID] ( @records = , @type = 102, @power = 1, @department = 1, @id = 1 ).

将 nvarchar 值 '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 '%' 转换为数据类型为 int 的列时发生语法错误。
没有行受影响。
...全文
评论 17
收藏 已收藏
分享
返回顶部
sheixiu
MS-SQL Server 34,877 成员 254,635 内容