check if the table is already existing

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

  1. #1

    Default check if the table is already existing

    I need to check if the table is already existing in the database before
    creating a new table dynamically. If the table is already there then I have to
    display the table columns and the datatypes. Can anyone help me how can i do
    this?

    Merlyn MM Guest

  2. Similar Questions and Discussions

    1. Creating A New Table In Existing Access Database
      Hi, I am trying to create a new table in an existing database and having some issues. When I use the attached code, it gives me an: Error...
    2. Creating new table with same structure as existing one
      I need to create "archive" table that will have the same structure as "production" one. When I run my program it have to create table named...
    3. Default Date and/or Times in Form to Existing Records of Table
      Fields are blank in the table. Want the default current date and times in fields upon entry of additional data in other blank fields. How can I...
    4. db2dart and check table
      (1). DB2 UDB Personal Edition does not support remote connections, only allow local connections. (2). Either part of a table or some tables got...
    5. How to place a new table around an existing one?
      I'm using DW MX on a powerbook. How do I place an existing table structure inside a new table? Or to put in another way how do I wrap a new table...
  3. #2

    Default Re: check if the table is already existing

    Another option would be to use CFPARAM to ensure that the form field values
    exist.

    Since FORM is a structure, you can also use this syntax instead of evaluate:
    #form["Tour"& ThisRow]#

    I noticed the single quotes around most of the values in the query. Are
    "NumberAttending", "Tour", "Mixer", etc... "text" columns? If so, you might
    want to use column data types that more accurately reflects the kind of values
    contained in each column (in this case numeric and yes/no). For example, if
    "NumberAttending" should only contain numbers, then the column type should
    really be numeric not text. You probably wouldn't want someone entering "I am
    bringing my entire extended family!" in the "NumberAttending" column : )


    mxstu Guest

  4. #3

    Default Re: check if the table is already existing

    There are probably a few methods for accommplishing this, but the specifics
    depend on the type of database you are using. For example, SQL Server provides
    "views" of system information like table objects and table columns, which can
    be used to determine if a table exists or to retrieve information about table
    columns.

    -- should be modified to filter on database and table owner
    IF NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME =
    'YourTable')
    BEGIN
    -- some code here...
    END
    ELSE
    BEGIN
    SELECT COLUMN_NAME, DATA_TYPE
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'YourTable'
    END

    For security and other reasons, you may want to establish a special user/login
    in the database and grant it limited permissions for working with the dynamic
    objects. There are probably a number of both pros and cons to allowing an
    interface to dynamically create database objects, so you may want to
    investigate that aspect further.


    HTH


    mxstu 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