Here is the coalesce function I want to use to fetch all the contract ids separated by comma with contract title in where clause.
declare @tempContractID int
SELECT @tempContractID = COALESCE(@tempContractID,'') + ContractID + ','
FROM Icn_Contracts where title like '%t'
select @tempContractID as allcontrcats
But I get this error:
Conversion failed when converting the varchar value ',' to data type int.
When I use coalesce for fetching contract names then it does not show any error.