DBCC CHECKIDENT can't find the table

5.6k Views Asked by At

I have table that has an id which both an identity AND primary key of a table. When run this

Use devdb
Select * from tablename order by did desc

works and I see the data. When I run the following, I see the table in list

Use devdb
SELECT * FROM information_schema.tables order by TABLE_NAME

But when I run this:

Use devdb;
DBCC CHECKIDENT ('<TableName>.<ColumnName>', RESEED, 100000);

I get

Msg 2501, Level 16, State 45, Line 2
Cannot find a table or object with the name "<tablename>.<columnname>". Check the system      catalog.

Anyone know why?

2

There are 2 best solutions below

1
On BEST ANSWER

Check out the documentation for CHECKIDENT. It only takes in a table name because tables are restricted to only a single identity column so there is no need to give a column name. Just run:

Use devdb;
DBCC CHECKIDENT ('<TableName>', RESEED, 100000);
0
On

If your schema is not default ('dbo.TableName'), the command will fail. Make sure your use the correct ('schemaName.tableName') context