Question : An expression of non-boolean type specified in a context where a condition is expected

In the code below, while running i get the error
An expression of non-boolean type specified in a context where a condition is expected

what part of the code should i change to get rid of the error.

thanks
1:
2:
3:
4:
SELECT @table = TableName,@column = Columnblank from @tablestr where i = @j
SELECT @nsql = 'if not exists (select NULL from '+@table +' where '+@column+' is not null ) select @table,@column '
INSERT INTO tblColNOD
EXEC sp_executeSql @nsql,N' @table VARCHAR(100), @column VARCHAR(100) ', @table,@column

Answer : An expression of non-boolean type specified in a context where a condition is expected

Try this then, in case your column names contain spaces or some such.


SELECT @table = TableName,@column = Columnblank from @tablestr where i = @j
SELECT @nsql = 'if not exists (select NULL from '+quotename(@table) +' where '+QuoteName(@column)+' is not null ) select @table,@column '
INSERT INTO tblColNOD
EXEC sp_executeSql @nsql,N' @table VARCHAR(100), @column VARCHAR(100) ', @table,@column
Random Solutions  
 
programming4us programming4us