Both of the sentences are grammatically correct. However, I would advise you not to replace "which" with "that." If you must use "that" in a sentence, then you can re-write it, so it would like this:
I have three dogs, but only two that I really like.
- For Teachers