存储过程select语句返回的结果如何接收
CREATEPROCEDUREcopySourcelib(@NSIDINT,@subjectidNVARCHAR(100))ASDECLARE@articlensidIN...
CREATE PROCEDURE copySourcelib (@NSID INT ,@subjectid NVARCHAR(100) ) AS
DECLARE @articlensid INT
DECLARE @length INT
DECLARE @id INT =1
DECLARE @article VARCHAR(100)='1'
SET @length=SELECT count(id) FROM Split(@subjectid,',') 本行报select附近有语法错误
WHILE @id<=@length
BEGIN
SELECT @article=SELECT a FROM Split(@subjectid,',') WHERE id=@id 本行报select有语法错误
SELECT @articlensid=INSERT INTO sourcelib SELECT TITLE FROM sourcelib WHERE NSID =@NSID SELECT @@IDENTITY 本行报insert附近有语法错误
UPDATE sourcelib SET magazineID=@article,parentId=@NSID WHERE NSID=@articlensid
SELECT @article=INSERT INTO selectInfo SELECT NSID, operationPersonId FROM selectInfo WHERE NSID =@NSID SELECT @@IDENTITY 本行报insert附近有语法错误
UPDATE selectInfo SET NSID =@articlensid WHERE id=@article
SET @id=@id+1
END;
不知道我代码里insert返回的主键值接收是否正确?表中的字段比较多只留了一部分方便看代码 展开
DECLARE @articlensid INT
DECLARE @length INT
DECLARE @id INT =1
DECLARE @article VARCHAR(100)='1'
SET @length=SELECT count(id) FROM Split(@subjectid,',') 本行报select附近有语法错误
WHILE @id<=@length
BEGIN
SELECT @article=SELECT a FROM Split(@subjectid,',') WHERE id=@id 本行报select有语法错误
SELECT @articlensid=INSERT INTO sourcelib SELECT TITLE FROM sourcelib WHERE NSID =@NSID SELECT @@IDENTITY 本行报insert附近有语法错误
UPDATE sourcelib SET magazineID=@article,parentId=@NSID WHERE NSID=@articlensid
SELECT @article=INSERT INTO selectInfo SELECT NSID, operationPersonId FROM selectInfo WHERE NSID =@NSID SELECT @@IDENTITY 本行报insert附近有语法错误
UPDATE selectInfo SET NSID =@articlensid WHERE id=@article
SET @id=@id+1
END;
不知道我代码里insert返回的主键值接收是否正确?表中的字段比较多只留了一部分方便看代码 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
展开全部
SET @length=SELECT count(id) FROM Split(@subjectid,',')
改为SELECT @length=count(id) FROM Split(@subjectid,',')
SELECT @article=SELECT a FROM Split(@subjectid,',') WHERE id=@id
改为SELECT @article=a FROM Split(@subjectid,',') WHERE id=@id
SELECT @articlensid=INSERT INTO sourcelib SELECT TITLE FROM sourcelib WHERE NSID =@NSID SELECT @@IDENTITY
改为
INSERT INTO sourcelib SELECT TITLE FROM sourcelib WHERE NSID =@NSID
SELECT @articlensid=@@IDENTITY
你这个基本上都是赋值的错误,请参照上面给的修改方法把其他的都修改好后再调试。
改为SELECT @length=count(id) FROM Split(@subjectid,',')
SELECT @article=SELECT a FROM Split(@subjectid,',') WHERE id=@id
改为SELECT @article=a FROM Split(@subjectid,',') WHERE id=@id
SELECT @articlensid=INSERT INTO sourcelib SELECT TITLE FROM sourcelib WHERE NSID =@NSID SELECT @@IDENTITY
改为
INSERT INTO sourcelib SELECT TITLE FROM sourcelib WHERE NSID =@NSID
SELECT @articlensid=@@IDENTITY
你这个基本上都是赋值的错误,请参照上面给的修改方法把其他的都修改好后再调试。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询