Identity Column (SQL server)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zorpiedoman

    #1

    Identity Column (SQL server)

    I know this question should be posted in a SQL server newsgroup, but I can't
    find one. That's ok... it's understand that any VB.NET programmer is also an
    expert on SQL, right? :-)

    Anyway, I need to be able to figure out if a column in a table is an
    IDENTITY column. Any one know how to do this?

    --
    --Zorpie
  • Zorpiedoman

    #2
    RE: Identity Column (SQL server)

    I figured it out and wrote a UDF, if anyone ever needs this too:

    CREATE FUNCTION IdentityColumn( @TableName varchar(255))
    RETURNS varchar(255) AS
    BEGIN
    Return IsNull (
    (Select C.Name From syscolumns C inner join sysobjects T on T.ID = C.ID
    Where T.Name = @TableName and C.ColStat & 1 = 1)
    , ''
    )
    END
    -

    Comment

    Working...