'EXPORTS THE ACTIVE TABLE INTO A SQL IMPORTABLE DUMP 'WILL PRODUCE TWO SQL FILES ONE EACH FOR _CREATE TABLE_ AND FOR _INSERT INTO_ REQUESTS 'REQUIRES: ACTIVE TABLE 'LOADING SCRIPTS ' 1. Double-click on an empty area on the bar containing all buttons, The "Customize" dialog appears ' 2. In the "Type" pull-down, select "View" ' 3. In the "Category" pull-down, select "Buttons", The display right below the pull down changes to show an array of buttons ' 4. Slide the scrollbar (below the button display) to the right and select the last button by clicking on it, Now click on "New" ' 5. A new blank button appears. Double-click on the blank area to the right of the entry "Click" (just below the button display) ' 6. The "Script Manager" Dialog appears, Click on "New", Enter any name in the input box that appears (prefix it with "Z_" so that it goes in the last) ' 7. A new blank script document (With the name just specified) appears. Delete whatever is on it... ' 8. Either copy-paste this ENTIRE script on the document, or, click on the button with the open-folder icon (tooltip reads "Load text file") and navigate to this file ' 9. Either done, click on the button with the tick-mark icon ("compile"). If spatial analyst is not loaded, there will be some error message, Load it ' 10. After the script is compiled (the tick-mark buton should be grayed out), close the script window and return to the view ' 11. Click on the new button to run the script TheTable=av.GetActiveDoc TheVtab=Thetable.GetVtab TheFields1=TheVtab.GetFields TheFields =msgbox.multilist(TheFields1,"Choose Fields to include","Choose Fields") File1=FileDialog.Put("DescriptorFile.sql".AsFileName,"*.sql","Specify Location for First SQL query") File2=FileDialog.Put("DataFile.sql".AsFileName,"*.sql","Specify Location for Second SQL query") 'msgbox.info(TheTable.GetName.left((TheTable.GetName.Count)-4),"Name of table") TableName= TheTable.GetName '.left((TheTable.GetName.Count)-4) aLF=LineFile.Make(File1,#FILE_PERM_WRITE) ctr=0 aLF.WriteELT("CREATE TABLE"++TableName++"(") FldCnt=(TheFields.Count)-1 ctr=0 for each fld in TheFields fName=fld.GetName fType=fld.GetType if ((ftype=#FIELD_LONG) OR (ftype=#FIELD_SHORT)) then ftypesql="INT" fLeng=fld.GetWidth fstr=ftypesql++"("+fLeng.AsString+")" elseif ((ftype=#FIELD_CHAR) OR (ftype=#FIELD_VCHAR)) then ftypesql="VARCHAR" fLeng=fld.GetWidth fstr=ftypesql++"("+fLeng.AsString+")" elseif ((ftype=#FIELD_DECIMAL) OR (ftype=#FIELD_DOUBLE) OR (ftype=#FIELD_FLOAT)) then ftypesql="DOUBLE" fLeng=fld.GetWidth fstr=ftypesql++"" end if (ctr = FldCnt) then aLF.WriteELT(fName++fstr+");") else aLF.WriteELT(fName++fstr+",") end ctr=ctr+1 end bLF=LineFile.Make(File2,#FILE_PERM_WRITE) for each rec in TheVtab midstr="" for each f in TheFields ftype=f.GetType val = TheVtab.ReturnValue(f,rec) if ((ftype=#FIELD_LONG) OR (ftype=#FIELD_SHORT)) then val1=val.AsString val2=val1.UnQuote elseif ((ftype=#FIELD_CHAR) OR (ftype=#FIELD_VCHAR)) then val2=val.AsString.Quote elseif ((ftype=#FIELD_DECIMAL) OR (ftype=#FIELD_DOUBLE) OR (ftype=#FIELD_FLOAT)) then val1=val.AsString.UnQuote val2=val1.UnQuote end midstr=midstr+val2+"," end intstr="INSERT INTO"++TableName++"VALUES (" endstr=");" wholestr=intstr++midstr++endstr TheStr=wholestr.substitute(", );",");") bLF.WriteELT(TheStr) end msgbox.info("Process Complete","Process Complete")