2. Regarding the set
$$
S=\left\{a \mid a \in \mathbf{Z} \text {, and } \frac{a^{2}-a+88}{a^{3}+1} \in \mathbf{Z}\right\}
$$

the correct statement about the number of elements $|S|$ is ( ).
(A) $|S|=2$
(B) $|S|=3$
(C) $|S|=4$
(D) $|S| \geqslant 5$
2.B.

From the given condition, we have
$(a+1)\left(a^{2}-a+1\right) \mid\left(a^{2}-a+88\right)$.
Then $\left(a^{2}-a+1\right) \mid\left(a^{2}-a+88\right)=\left(a^{2}-a+1\right)+87$.
Thus, $\left(a^{2}-a+1\right) \mid 87=3 \times 29$.
Since $a^{2}-a+1>0$, from equation (1) we get
$a^{2}-a+1=1,3,29,87$.
When $a^{2}-a+1=1$, $a=0$ or 1, which satisfies the condition.
When $a^{2}-a+1=3$, $a=-1$ (discard) or 2, which satisfies the condition.
When $a^{2}-a+1=29$ or 87, there are no integer solutions.
In summary, the required $S=\{0,1,2\}$.