In interrogative clauses, this fragment is typically used either with a negative adverb, such as pas or jamais, or with a negative object, such as rien. Hence "N'y a-t-il pas de trains ?", "N'y a-t-il rien à faire ?", and so on. See ne.
It may also be used in declarative clauses after a modal adverb or after jamais (see examples and quotations).