Professional Web Applications Themes

Autonumeric type? - Microsoft SQL / MS SQL Server

Hello, I'm doing a query with an SQLQuery to MSSQL 2000. I'm trying to make a list of the fields of a table and their types. I know the data types except one: autonumeric. When I design a table, an autonumeric field it's a integer field with the identity property. How can I know if an integer type is an autonumeric type? I look into syscolumns table for the field, but it appears like an integer. Is there any field in this table which defines the autonumeric (or identity) property? Maybe typestat column? -- Oscar Espinosa EgaraSet, S.L....

  1. #1

    Default Autonumeric type?

    Hello,

    I'm doing a query with an SQLQuery to MSSQL 2000. I'm trying to make a list
    of the fields of a table and their types. I know the data types except one:
    autonumeric.
    When I design a table, an autonumeric field it's a integer field with the
    identity property. How can I know if an integer type is an autonumeric type?
    I look into syscolumns table for the field, but it appears like an integer.
    Is there any field in this table which defines the autonumeric (or identity)
    property?

    Maybe typestat column?

    --
    Oscar Espinosa

    EgaraSet, S.L.


    Oscar Guest

  2. #2

    Default Re: Autonumeric type?

    Use the COLUMNPROPERTY function. See Books Online for more information.
    --
    HTH,
    Vyas, MVP (SQL Server)
    http://vyaskn.tripod.com/
    What hardware is your SQL Server running on?
    http://vyaskn.tripod.com/poll.htm


    "Oscar Espinosa (Egaraset, S.L.)" <com> wrote in message
    news:phx.gbl...
    Hello,

    I'm doing a query with an SQLQuery to MSSQL 2000. I'm trying to make a list
    of the fields of a table and their types. I know the data types except one:
    autonumeric.
    When I design a table, an autonumeric field it's a integer field with the
    identity property. How can I know if an integer type is an autonumeric type?
    I look into syscolumns table for the field, but it appears like an integer.
    Is there any field in this table which defines the autonumeric (or identity)
    property?

    Maybe typestat column?

    --
    Oscar Espinosa

    EgaraSet, S.L.



    Narayana Guest

  3. #3

    Default Re: Autonumeric type?

    Hi Oscar,

    You can use COLUMNPROPERTY(OBJECT_ID('MyTable'), 'Mycolumn', 'IsIdentity')
    to find out if the column has the identity property.

    Example:
    USE Northwind
    IF COLUMNPROPERTY(OBJECT_ID('employees'), 'EmployeeID', 'IsIdentity') = 1
    SELECT 'Has Identity'
    ELSE SELECT 'Ordinary column'

    --
    Jacco Schalkwijk MCDBA, MCSD, MCSE
    Database Administrator
    Eurostop Ltd.


    "Oscar Espinosa (Egaraset, S.L.)" <com> wrote in message
    news:phx.gbl... 
    list 
    one: 
    type? 
    integer. 
    identity) 


    Jacco Guest

  4. #4

    Default Re: Autonumeric type?

    Take a look at listTableColumns
    http://www.aspfaq.com/2177





    "Oscar Espinosa (Egaraset, S.L.)" <com> wrote in message
    news:phx.gbl... 
    list 
    one: 
    type? 
    integer. 
    identity) 


    Aaron Guest

  5. #5

    Default Re: Autonumeric type?

    >> How can I know if an integer type is an autonumeric type? <<

    Strictly speaking you cannot, because autonumeric is not a valid datatype in
    SQL Server. One option to check if a table has an identity column is to use
    the meta-data function OBJECTPROPERTY with TableHasIdentity property. To
    check if a column is an identity column you can use IsIdentity property of
    the meta-data function COLUMNPROPERTY.

    See SQL Server Books Online for more details on this.

    --
    - Anith
    ( Please reply to newsgroups only )


    Anith Guest

Similar Threads

  1. Replies: 4
    Last Post: February 22nd, 06:11 AM
  2. Error: Webcontrol must have items of type X. SubLinks is of type Y
    By ~~~ .NET Ed ~~~ in forum ASP.NET Building Controls
    Replies: 2
    Last Post: November 10th, 05:15 PM
  3. Problem with character palette and Tracking field: can't type zero after type is modified
    By Tim_Murray@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 0
    Last Post: May 11th, 04:21 PM
  4. Cast from type 'Field' to type 'String'
    By in forum ASP Database
    Replies: 2
    Last Post: November 11th, 03:18 PM
  5. Cast from type 'DBNull' to type 'String' is not valid error
    By Rob in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: July 28th, 09:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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