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

  1. #1

    Default Select Primary Key

    Hi

    Is there any way to select Primary key from table . If you do not know your
    primary key. I mean can we make any condition or check in which select
    statement will only select the primary key.

    Thanks
    Jon

    akcreative Guest

  2. Similar Questions and Discussions

    1. Primary Scratch & Windows Primary Paging file?
      Okay, I accidentally uninstalled Adobe Photoshop the other day. So I re-installed it and now when I click on the Photoshop Icon and it starts to...
    2. #25474 [Bgs]: posting arrays from a select box with multiple select is not working properly
      ID: 25474 User updated by: fmuller at cisco dot com -Summary: apache2filter: posting from a multiple select box is not...
    3. How do you select a row if you know the value of the row's primary key?
      I would like to know how to select the correct row of the datagrid knowing only the value of its DataKeyField. Could someone please tell me how to...
    4. #25474 [Fbk->Opn]: posting arrays from a select box with multiple select is not working properly
      ID: 25474 User updated by: fmuller at cisco dot com Reported By: fmuller at cisco dot com -Status: Feedback...
    5. SELECT DISTINCT + ORDER BY gives ERROR 145: ORDER BY items mustappear in the select list if SELECT DISTINCT is specified.
      Dan, You should be able to do this: SELECT Id, FaxID, ReceivedTime, Pages FROM ( SELECT DISTINCT .Id AS Id,
  3. #2

    Default Re: Select Primary Key

    In some databases you can find out the primary key by querying the system tables, assuming you have permission to do so. The specifics are db dependent.
    Dan Bracuk Guest

  4. #3

    Default Re: Select Primary Key

    Hi

    I can see many System tables in my database. Can you please give me an example. That will help me alot. Thanks, Jon
    akcreative Guest

  5. #4

    Default Re: Select Primary Key

    On a philosophical note, it seems to me that if you don't know enough about
    your data model / database / schema to know what your keys are, then you
    probably shouldn't be doing any queries until you do. Kind of like hunting in a
    cave without a flashlight.

    Phil

    paross1 Guest

  6. #5

    Default Re: Select Primary Key

    Thanks alot for your help.

    I am using SQL server. Actually I am trying to create a CFC that will check
    the database dependency. I know my databse well. But I am trying to create a
    tree relationship of database programically

    Thanks Jon

    akcreative Guest

  7. #6

    Default Re: Select Primary Key

    You may want to take a look at SQL Server Books online (BOL) and research
    Catalog Functions.

    For example:

    SQLPrimaryKeys uses the catalog stored procedure sp_pkeys to report primary
    key participants from a table. Though a table may have a column or columns that
    can serve as unique row identifiers, tables created without a PRIMARY KEY
    constraint return an empty result set to SQLPrimaryKeys. The ODBC function
    SQLSpecialColumns reports row identifier candidates for tables without primary
    keys.

    Phil



    paross1 Guest

  8. #7

    Default Re: Select Primary Key

    hi

    did not have any clue how can i use SQLPrimaryKeys

    thanks
    akcreative Guest

  9. #8

    Default Re: Select Primary Key

    I take it that you don't have access to BooksOnLine? It is free to download
    from Microsoft, and you would be well advised to do so.

    You could look at your sysconstraints table, but then you get into table IDs
    and column IDs and status flags, etc. Not much help without a roadmap.

    Phil

    paross1 Guest

  10. #9

    Default Re: Select Primary Key

    Paross1 is right. Books Online and a little of sweat. Anyway, a little help
    this time :

    SELECT kcu.table_name,kcu.column_name
    FROMinformation_schema.TABLE_CONSTRAINTS
    tc,information_schema.KEY_COLUMN_USAGE kcu
    WHERE tc.constraint_type='PRIMARY KEY' AND
    tc.CONSTRAINT_NAME=kcu.CONSTRAINT_NAME

    Regards

    Sojovi 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