0
    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

我收到此错误请告诉我如何解决此错误

4

1 回答 1

1
INSERT INTO @tblTopics 
SELECT  @TopicsFilterFranchiseId = ID from dbo.GetIDsTableFromIDsList(@FranchiseID)

以上代码无效。

而是选择具有要插入的值/列的语句。

例如

INSERT INTO @tblTopics 
SELECT  @ClientCategoryID,@CategoryId,@Productid 

在插入语句之前为变量赋值,您不能在同一语句中为变量赋值并插入表。

于 2013-09-17T11:28:40.830 回答