DECLARE @TopicsFilterFranchiseId INT
DECLARE @tblTopics AS table
(
ClientCategoryID int,
CategoryID int,
ProductID int
)
INSERT INTO @tblTopics
SELECT @TopicsFilterFranchiseId = ID from dbo.GetIDsTableFromIDsList(@FranchiseID)
while @TopicsFilterFranchiseId is not null
begin
EXEC SBS_G_GetTopicsByFranchiseID @TopicsFilterFranchiseId
Set @TopicsFilterFranchiseId = NULL
end
我收到此错误请告诉我如何解决此错误
答案 0 :(得分:1)
INSERT INTO @tblTopics
SELECT @TopicsFilterFranchiseId = ID from dbo.GetIDsTableFromIDsList(@FranchiseID)
以上代码无效。
而是具有要插入值/列的select语句。
E.g
INSERT INTO @tblTopics
SELECT @ClientCategoryID,@CategoryId,@Productid
在insert语句之前为变量赋值,不能将值赋值给变量并在同一语句中插入表中。