Click here to Skip to main content
12,349,785 members (23,836 online)
Rate this:
 
Please Sign up or sign in to vote.
I want to fetch the indentity specification details(identity increment and identity seed) of a column of a table in sql server. Is there any way to fetch the specified details in stored procedure or using asp.net c# code?
Posted 7-Oct-12 21:13pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Use the below code to fetch the schema detail from the data base

string conString = //your connection sting
string query = "select * from tableName";
SqlConnection con = new SqlConnection(conString);
 
try
{
   con.Open();
   SqlCommand cmd = new SqlCommand(query, con);
   SqlDataReader reader = cmd.ExecuteReader();
   //Below schema obj contain the schema of the table
   DataTable schema = reader.GetSchemaTable();
   //Schema obj has all the details that you want
   reader.Close();
}
catch(Exception e)
{
   Console.WriteLine("Error Occurred: " + e);
}
finally
{
   conn.Close();
}

Hope this will help you
  Permalink  
v4
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

I got the solution:
SELECT IDENT_CURRENT('tblEmployee') AS LastIdentityValue
SELECT IDENT_SEED('tblEmployee') AS seed
SELECT IDENT_INCR('tblEmployee') AS Increment
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Hi

pls try this

select is_identity,seed_value,increment_value from sys.identity_columns where name = '[colum name]'


if this is not your solution please give some more clarification


Thanks

Shiju
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100