I have a stored procedure where I am declaring an int variable that needs to be populated using a dynamic sql
CREATE PROCEDURE USP_aTABLE_ADD
/*
stored procedure variables
*/
AS
DECLARE @count int
SET @count = 1
DECLARE @qry nvarchar(max)
/*
SET UP @qry which will look like this
SELECT @count = count(*) FROM aTABLE WHERE (col1 = 'val1' AND col2 = 'val2'...)
*/
/*
How to get the value of @count so that I can continue with add process
*/
IF @count = 0
BEGIN
/*add logic*/
END
@count, so what's the problem?