May 11, 2010 at 10:33 pm
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.
May 11, 2010 at 11:49 pm
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!
May 11, 2010 at 11:55 pm
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!
May 12, 2010 at 12:27 am
Thank you, :Whistling: this helps me to reach my requirement.
May 12, 2010 at 12:57 am
Glad i could help! You're welcome! 🙂
May 12, 2010 at 1:59 am
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.
May 12, 2010 at 2:29 am
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