If I have column with AUTO_INCREMENT in person
table that was start with 1 and incremented by 2
now after I add a row in that table
I have
ID|Fname|Lname
---------------
1 |check|check2
3 |check3|check4
How in a SQL query can I get the status of the increment I mean I want to get in the SQL the value now and the increment by
In that example I want to get from the query like:
select
increment_value, increment_by
from
INFORMATION_SCHEMA.COLUMNS/sys.columns
where
tablename= 'Person'
the result that I want to get is 3,2
if people is stuck with the same situation so
here my last code
in c#
//check columns is auto incresment if yes = True or or not =False
string sql1 = string.Format("SELECT is_identity FROM sys.columns WHERE object_id = object_id('{0}') AND name = '{1}'","tablename","ColumnName");
string str = DoQueryWithReturn("db.mdf", sql1);
MessageBox.Show(str[0]);
//get the ident increment Seed = start value , INCR= how many it up , Current it what number right now, last row
sql1 = string.Format(" SELECT IDENT_SEED('{0}'),IDENT_INCR ('{0}'),IDENT_CURRENT('{0}') AS Identity_Seed ", "tablename");
str = DoQueryWithReturn("db.mdf", sql1);
if(str[0].Length!=0)
MessageBox.Show(str[0]+","+str[1]+","+str[2]);