declare @tags1 varchar(max)
declare @blockcount int
declare @blockstring varchar(max)
set @tags1='%Gifts%' Or CategoryTag Like'%Packaging%'
set @blockstring= 'SELECT @blogcount=count(*) FROM M_PHBLogs where CategoryTag LIKE '+ @tags1 +' AND ContentType=1 '
exec (@blockstring)
我想将exec(@blockstring)的结果存储到另一个变量中,如
@blockcount=exec(@blockstring)
if(@blockcount!=0)
BEGIN
//something
END
答案 0 :(得分:0)
使用sp_executesql
。实际上,您应该始终使用此功能,因为它允许参数化。
declare @tags1 varchar(max);
declare @blockcount int;
declare @blockstring varchar(max);
set @tags1 = '''%Gifts%'' Or CategoryTag Like ''%Packaging%''';
set @blockstring= 'SELECT @blogcount = count(*) FROM M_PHBLogs where CategoryTag LIKE '+ @tags1 +' AND ContentType = 1';
exec sp_executesql @blockstring, N'@blockcount int output', @blockcount = @blockcount;
答案 1 :(得分:0)
使用# draws contours in white color, outlines only (not filled)
cv2.drawContours(dst, contours, -1, (255,))
cv2.imshow("result", dst)
cv2.waitKey(-1)
请记住sp_executesql
这样称呼:
declare @blockstring nvarchar(max)
答案 2 :(得分:0)
不是EXEC(据我所知),但使用 sp_ExecuteSQL ,您可以定义参数并将这些参数作为输入或输出传递给动态创建的SQL脚本
以下是SQL脚本的简化版
Range("RegionSAEC")
请阅读教程Use sp_ExecuteSQL T-SQL Stored Procedure with Input and Output Parameters以获取有关如何在sp_executesql中使用参数的更详细示例