Extract the sql