Link to home
Start Free TrialLog in
Avatar of timmae
timmaeFlag for United States of America

asked on

Update Identity seed programatically

I found the query below that returns the Identity info for all the tables in a db.  I would like to know if it's possible to write an update query that would update the seed to the current_identity + 1.  The db is a copy so all the seeds were reset to 1.
SELECT  IDENT_SEED(TABLE_NAME) AS Seed,
	IDENT_INCR(TABLE_NAME) AS Increment,
	IDENT_CURRENT(TABLE_NAME) AS Current_Identity,
	TABLE_NAME
FROM    INFORMATION_SCHEMA.TABLES
WHERE   OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 1
	AND TABLE_TYPE = 'BASE TABLE'

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David Todd
David Todd
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of timmae

ASKER

It seemed fair to split the points on this one.  Thank you both for your help.