I am not a native speaker but AFAIK, ONLY if word starts with a vowel sound, then we say an. else, a is used. 

so, `a SQL fragment` seems okay to me.