请问下,如何往储存过程中传入‘,’的字符串

waitinglines 2008-03-10 02:48:50
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO




------------------------------------
--用途:增加一条记录
--项目名称:
--说明:
--时间:2008-3-5 15:18:35
------------------------------------
ALTER PROCEDURE UP_Questions_ADD
@itemid int ,
@itemValue varchar(1000)

AS
INSERT INTO Questions(
[author],[Q_Note],[Q_Content],[ImageName],[HiteCounter],[AnsCounter],[ReleaseTime],[ReferTime],[BigClass_ID],[SmallClass_ID],[kind],[solved]
) select top 20 'waitingline' as author,title,content,
photourl,
'0' as HiteCounter,
'0' as AnsCounter,
getdate() as ReleaseTime,
getdate() as ReferTime,
(select bigclassid from zl_collitem where zl_collitem.[id]=zl_collection.itemid) as BigClass_ID,
(select smallclassid from zl_collitem where zl_collitem.[id]=zl_collection.itemid) as smallclass_ID,
'1' as kind,
'0' as solved from zl_collection
where itemid=@itemid and [id] in (@itemValue)

delete from zl_collection where itemid=@itemid and [id] in (@itemValue)


服务器: 消息 245,级别 16,状态 1,过程 UP_Questions_ADD,行 16
将 varchar 值 '19,20' 转换为数据类型为 int 的列时发生语法错误。










GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
...全文
66 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
waitinglines 2008-03-18
  • 打赏
  • 举报
回复
呵呵,本人刚来,分数比较少!
utpcb 2008-03-10
  • 打赏
  • 举报
回复
分数太少了呵呵
-狙击手- 2008-03-10
  • 打赏
  • 举报
回复
更正一下,id => rtrim(id)
-狙击手- 2008-03-10
  • 打赏
  • 举报
回复
更正一下,id => rtrim(id)
-狙击手- 2008-03-10
  • 打赏
  • 举报
回复
ALTER     PROCEDURE UP_Questions_ADD 
@itemid int ,
@itemValue varchar(1000)

AS
INSERT INTO Questions(
[author],[Q_Note],[Q_Content],[ImageName],[HiteCounter],[AnsCounter],[ReleaseTime],[ReferTime],[BigClass_ID],[SmallClass_ID],[kind],[solved]
) select top 20 'waitingline' as author,title,content,
photourl,
'0' as HiteCounter,
'0' as AnsCounter,
getdate() as ReleaseTime,
getdate() as ReferTime,
(select bigclassid from zl_collitem where zl_collitem.[id]=zl_collection.itemid) as BigClass_ID,
(select smallclassid from zl_collitem where zl_collitem.[id]=zl_collection.itemid) as smallclass_ID,
'1' as kind,
'0' as solved from zl_collection
where itemid=@itemid and charindex(','+[id]+',',','+@itemValue+',') > 0

delete from zl_collection where itemid=@itemid and charindex(','+[id]+',',','+@itemValue+',') > 0
pt1314917 2008-03-10
  • 打赏
  • 举报
回复

ALTER PROCEDURE UP_Questions_ADD
@itemid int ,
@itemValue varchar(1000)

AS
INSERT INTO Questions(
[author],[Q_Note],[Q_Content],[ImageName],[HiteCounter],[AnsCounter],[ReleaseTime],[ReferTime],[BigClass_ID],[SmallClass_ID],[kind],[solved]
) select top 20 'waitingline' as author,title,content,
photourl,
'0' as HiteCounter,
'0' as AnsCounter,
getdate() as ReleaseTime,
getdate() as ReferTime,
(select bigclassid from zl_collitem where zl_collitem.[id]=zl_collection.itemid) as BigClass_ID,
(select smallclassid from zl_collitem where zl_collitem.[id]=zl_collection.itemid) as smallclass_ID,
'1' as kind,
'0' as solved from zl_collection
where itemid=@itemid and
--[id] in (@itemValue) 改为
charindex(','+ltrim(id)+',',','+@itemValue+',') >0

delete from zl_collection where itemid=@itemid and
--[id] in (@itemValue)改为
charindex(','+ltrim(id)+',',','+@itemValue+',')>0

22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧