add lock to function access_sql_server