declare @CName as varchar(50)='SalInvNo'; declare @qry as nvarchar(500) declare @count as int set @qry='select @count = count(*) from table; set @qry+=' where '+@CName+' <> 0'; exec sp_executesql @qry, N'@count int OUTPUT', @count OUTPUT
Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value 'SalINV1' to data type int.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)