exec('insert into ' +@tablename+ ' values(@caname,@firsturl,@num,@secondurl,@fromurl,@flg)')
修改一下:
exec('insert into ' +@tablename+ ' values('+@caname+ ','+@firsturl+ ','+@num+ ','+@secondurl+ ','+@fromurl+ ','+@flg+ ')')
因为exec() 相当于调用另一个存储过程,
在另一个存储过程中,你没有声明变量 @totalCount
sp_executesql [ @statement = ] statement
[
{ , [ @params = ] N'@parameter_name data_type [ OUT | OUTPUT ][ ,...n ]' }
{ , [ @param1 = ] 'value1' [ ,...n ] }
]