Is there any way to get the return value from the following SQL script?
ALTER PROCEDURE spInvert
(@Id INT, @column CHAR(1))
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ColumnValue CHAR(1)
DECLARE @Query VARCHAR(1000)
SET @Query = 'select Top 1 ' + @column + ' from TEST5 where Id = ''' + @Id + ''
SET @ColumnValue = EXEC(@Query) // here I need to get the column value
END
The @ColumnValue
will be 1 or 0. I am expecting single value from @ColumnValue
. I want to check if the @ColumnValue
is NULL or not. If Not Null, I want to update a table with this @ColumnValue
.
Thanks in advance