MapInfo Pro Developers User Group

 View Only
  • 1.  Delete All Columns After Specific Column

    Posted 03-19-2024 15:07

    Is there a way to delete all columns in a table after a specified column name?  I have a table named Locations and want to delete every column that exists after a column named Lead_lengt.

    Another way to consider it is Lead_lengt is column #162, is there a way to delete all after that column #?



    ------------------------------
    Jim
    ------------------------------


  • 2.  RE: Delete All Columns After Specific Column

    Posted 03-20-2024 02:27

    As a small mapbasic application, it could look like this:

    dim s as string
    dim i as integer
    dim N as integer
     
    s = "alter table xxx (drop "
    N = tableinfo(xxx,TAB_INFO_NCOLS)
     
    for i = 163 to N
      s = s+columninfo(xxx,"COL"+str$(i),COL_INFO_NAME)
      if i=N then 
        s = s+")"
      else
        s = s+","
      end if
    next
     
    run command s

    xxx is the tablename.



    ------------------------------
    Uffe Kousgaard
    CEO
    ROUTEWARE
    Roskilde
    ------------------------------



  • 3.  RE: Delete All Columns After Specific Column

    Posted 03-20-2024 10:26

    Thanks, Uffe.  That does exactly what I needed it to do.  I envy the programming skills that some of you guys have!



    ------------------------------
    Jim
    ------------------------------