Identity Column (SQL server)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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
-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top