I want to execute a dynamic query to get the affected row count. But SQL Result pane returns me the result after executing it. How to avoid returning the columns. I tried the below way.
DECLARE @Command NVARCHAR(MAX)= 'SELECT * FROM Product WHERE ID = 12'
DECLARE @Count AS INT
EXEC sp_executesql @Command, N'@C INT OUTPUT', @C=@Count OUTPUT
IF (@Count > 0)
BEGIN
EXECUTE (@Command)
END
ELSE
BEGIN
DECLARE @CatalogProduct VARCHAR(MAX) = 'SELECT p.ManufactureCode,p.PartNo,p.Size,p.ID AS ProductID,p.Name ,p.ParentProductID,p.BasePrice FROM Product.Product p WHERE p.ThruDate > GETDATE() '+@Where
EXECUTE (@CatalogProduct)
END
END
I want to avoid returning the null column set from the above attached image.