Empty data tables - Check

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

  1. #1

    Default Empty data tables - Check


    How can I check to see if a data table is empty so that I can set the ID value the first time?

    thanks

    CF_starter Guest

  2. Similar Questions and Discussions

    1. Check Empty form fields
      Hi all, Is there a simple extension that checks so that a form filed is not empty before submitting?
    2. How do you check for empty results
      I am pulling some XML in from PHP. Everything works fine until there are no results. My XML is formed like this: <books> <book> <title>Book...
    3. Why does CT drop empty lines in tables
      One of the pages on my clients website doesn't publish properly. My client does the updates using CT3. The page update is a simple cut and paste...
    4. check if querystring is empty
      if Request.QueryString("sub1")="" then 'it's empty else 'it's something end if "Thomas Henz" <thenz@t-online.de> wrote in message...
    5. RegularExpressionValidator - check for empty field
      Hi all, I want to use RegularExpressionValidator to enforce non-empty integer format in a TextBox. However, the validator doesn't give the error...
  3. #2

    Default Re: Empty data tables - Check

    I assume "ID" is not some sort of auto incrementing record ID column?

    It depends on your database. In an ms sql database, you could use "if not
    exists ...". You could also count the number of records in the table and if it
    is zero, execute some code.

    --- ms sql database
    if not exists (select someColumn from yourTable)
    begin
    do something here...
    end


    mxstu Guest

  4. #3

    Default Re: Empty data tables - Check

    select count(id) as thecount from mytable

    I assume you have a plan for setting the id field the first time, and incrementing it.
    Dan Bracuk Guest

  5. #4

    Default Re: Empty data tables - Check

    You probably need to know what the ID is for your programming.
    Try looking up @@identity. It will tell you the ID AFTER the insert query.
    chuckbeckwith Guest

  6. #5

    Default Re: Empty data tables - Check

    Yes, I do have a plan for setting the record. I am going use MS-SQL 2000 as
    the finished product. Right now I'm testing with MS-Access. I'm just trying to
    figure out how to do it, I tried MAX but got no value back.

    g

    CF_starter Guest

  7. #6

    Default Re: Empty data tables - Check

    If you are using Access and migrating to SQL Server, why not just use an
    autonumber column and run SELECT @@IDENTITY after your inserts like
    chuckbeckwith suggested? (Note - You will need to wrap both the INSERT and
    SELECT @@IDENTITY queries in a CFTRANSACTION) Then when you migrate to SQL
    Server the autonumber column will likely become an identity column and you can
    use one of SQL Server's identity functions.

    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