How to check whether a column is autoincrement

  • Dear all,

    I have the following select statement:

    SELECT (column_name +' '+'('+data_type+ ' '+IsNull(CAST(character_maximum_length as varchar(5)), '')+')') AS columnInfo FROM INFORMATION_SCHEMA.COLUMNS WHERE (TABLE_NAME = 'test') ORDER BY COLUMN_NAME

    How can i select only the columns that are not autoincrement?

    Thanks in advance.

  • the views from INFORMATION_SCHEMA stuff are missing a lot of info;

    to get theidentity or not,i would either use the ColumnProperty() function, or select from sys.columns instead.

    select * from sys.columns where is_identity=0

    select object_name(id),name,columnproperty(id,colid,'IsIdentity') from syscolumns

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply