sp_columns for microsoft access

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default sp_columns for microsoft access

    hello all

    in sql server, i can us the stored procedure sp_columns to get the table
    information (rownames, type, length etc) of a 'unknown' table. now, i need to
    write a routine to import tables from microsoft access databases into sql
    server. but sp_columns does not work on access.

    how can i tickle that information out of access using coldfusion and
    sql-queries? anybody any wiser than me? :)

    cheerios

    lukas @ switzerland

    woddel Guest

  2. Similar Questions and Discussions

    1. [microsoft][odbc microsoft access driver] syntax error (missing operator) in query expression error
      I have a query I want to run using DBQwiksite siftware, which produces the syntax error (missing operator) in query expression error when...
    2. [Microsoft][ODBC Microsoft Access Driver] Could not start session.
      Does anyone know what this problem means??? Microsoft OLE DB Provider for ODBC Drivers error '80004005' Could not start session. ...
    3. [Microsoft][ODBC Microsoft Access Driver]'(unknown)' is not a valid path error
      This is probably an old problem that most of you know how to fix (I hope!). The scenario is that I have a web server running an ASP site that needs...
    4. ASP Microsoft Access
      I am writing an sites for mulitple languages, even though in the script I tell the encoding type to be for the language in Microsoft Access it...
    5. Microsoft Access with ASP.net
      Is it possible to use ASP.net with Microsoft Access. From what I can find ASP.net only works with SQL server. That's kind of step backward from...
  3. #2

    Default Re: sp_columns for microsoft access

    There are no straight SQL queries to return Access table schema; it's not available through the ODBC driver. You have to use VB/ADO to get the info.
    philh Guest

  4. #3

    Default Re: sp_columns for microsoft access

    It can be done but its pretty messy - firstly you can get table names from the
    MSysObjects table - this is normally hidden but you can show it through the
    options menu. The following query will give you all table names:

    SELECT Name
    FROM MSysObjects
    WHERE Type = 1

    You then need to select one row of data (use maxrows=1) from each table and
    serialise it using wddx. This reveals column names in their correct order and
    also shows the data types.

    Below is a snippet of code I used to use to get this info from an Access 97
    database the field names are stored as a list in #fieldnames# and data types in
    #fieldtypes# - hope this helps.

    cheers.



    <cfquery name="qryColumns" datasource="#dsn#" maxrows="1">
    SELECT * FROM #tablename#
    </cfquery>

    <!--- convert any dates so that wddx serialisation doesn't crash.. --->
    <cfloop index="cname" list="#qryColumns.ColumnList#">
    <cfif IsDate(Evaluate("qryColumns."& cname))>
    <cfset "qryColumns.#cname#" = DateFormat(Evaluate("qryColumns."&
    cname),"yyyy-mm-dd") & " " & TimeFormat(Evaluate("qryColumns."&
    cname),"HH:MM:SS")>
    </cfif>
    </cfloop>

    <!---
    make into wddx packet so that column names are put into correct order
    and also so we can identify the data type of each column
    --->
    <cfwddx action="cfml2wddx" input="#qryColumns#" output="qWDDX">
    <cfset fieldnames = "">
    <cfset fieldtypes = "">
    <cfset nextpos = FindNoCase("<field name='", qWDDX, 1)>
    <cfloop condition="nextpos neq 0">
    <cfset nextpos = nextpos + 13>
    <cfset endpos = FindNoCase("'", qWDDX, nextpos)>
    <cfset fieldlen = endpos - nextpos>
    <cfset fieldnames = fieldnames & Mid(qWDDX, nextpos, fieldlen) & ",">
    <cfset nextpos = endpos + 3>
    <cfset endpos = FindNoCase(">", qWDDX, nextpos)>
    <cfset fieldlen = endpos - nextpos>
    <cfset fieldtypes = fieldtypes & Mid(qWDDX, nextpos, fieldlen) & ",">
    <cfset nextpos = FindNoCase("<field name='", qWDDX, nextpos)>
    </cfloop>

    efecto747 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139