If there are several tables, I would like to find out the value of col1 when col2 is null from these tables, and print the values through a stored procedure.
| col1 | col2 | 
|---|---|
| a | A | 
| b | null | 
| b | B | 
| c | C | 
| a | null | 
Expected ouput:
a,b
--what I did but can not work
create proc sp_getValue
@tableName varchar(30)
as
declare @result nvarchar(max)
select distinct col1=@result from @tableName
print @result
Thank you for your help.
 
     
    