cedwards65
Programmer
I am building dynamic SQL and want to execute that using the sp_executesql. When I execute the @sql_statement from the print statement in sqlserver I get a result, but when I execute it as below the @customer_id_out variable is still showing as null. Any ideas what I am doing wrong
DECLARE
@sql_statement Nvarchar(4000),
@customer_id_found int
SELECT @customer_id_found = null
select @sql_statement = @Sql_active + @product_list
print @sql_statement
exec sp_executesql @sql_statement,
N'@CID int out',
@customer_id_found out
IF ISNULL(@customer_id_found,'') <> ''
RETURN -1
DECLARE
@sql_statement Nvarchar(4000),
@customer_id_found int
SELECT @customer_id_found = null
select @sql_statement = @Sql_active + @product_list
print @sql_statement
exec sp_executesql @sql_statement,
N'@CID int out',
@customer_id_found out
IF ISNULL(@customer_id_found,'') <> ''
RETURN -1