Updated sql for role preperation