build sql script