As per my understanding the hidden script executes first and then the rest.
Also first you need to establish a connection and then executes.
Generally we dont add Sql queries in hidden script.
Hidden script are used for Section Access script or any other data information which we don't want to disclose to other developers.
Since the SQL Script doesn't contain any data , we don't write in hidden script.