declare @ids varchar(max)set @ids=''select @ids=@ids+','+convert(varchar(10),product_id) from tblProduct where PublishToWeb=1select @ids