declare @Count INT
select @Count = COUNT(*) from Invoice (nolock)
SET @Count = ISNULL(@Count, 0)
IF @Count > 0 AND (select COUNT(*) from Invoice (nolock) WHERE PrintDate IS NULL) = @Count
begin
  PRINT @Count
  update Invoice SET PrintDate = CreatedDate
  where printdate is null
end
