identity column

  • Hi all 🙂

    I want to create a table from already existing table which is passed to stored procedure as papameter. I used sysobjects, syscolumns, systypes to get the structure to create the table. I can identify whether the column is identity or not using colstat column in syscolumns. But, I am not able to findout the seed and increment of the identity column.

    Can any one help me to find Seed and increment for a column?

    Thanks in adavnce.

  • You can use IDENT_INCR and IDENT_SEED functions to get the seed and increment of a table/view.

    For more on them, click on them!

    Hope this helps you!

    Cheers!

  • If you wish to see the column names, then use the sys.identity_columns catalog view

    Sample SQL code for this:

    SELECT * FROM sys.identity_columns

    To read more about this, click here :- sys.identity_columns!

    Hope this helps you! Cheers!

  • Thank you, :Whistling: this helps me to reach my requirement.

  • Glad i could help! You're welcome! 🙂

  • Hi,

    This working fine. But, if I want to check for a table which is in other server or other database this command is not working. Can any body help me in this? :blink:

    Thanks in advance.

  • For another server, you can use

    SELECT * FROM <Your_Server_Name>.<Your_Database_Name>.sys.identity_columns

    provided you have the 2 servers linked using Linker Servers!

    Or you can use OPENROWSET or OPENDATASOURCE to access data on another server!

    For another database,

    SELECT * FROM <Your_Database_Name>.sys.identity_columns

    Hope this helps you!

    Cheers!

Viewing 7 posts - 1 through 6 (of 6 total)

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