Create function GetSQLFields and CreateSQLQuery