hi,
I have one database for eg 300 table ,i have delete specify the 200 table data only and then reseed identity the delete table .
but error withshown .
- DECLARE @DeleteTableStatement nvarchar(max)
- DECLARE C2 CURSOR READ_ONLY
- FOR
- SELECT 'Delete From [dbo].[' + TABLE_NAME + ']' from INFORMATION_SCHEMA.TABLES
- WHERE TABLE_SCHEMA = 'dbo' and TABLE_NAME NOT IN ('xxx',
- 'aaa',
- 'bbb',
- etc
- ) -- Change your schema appropriately.
- OPEN C2
- FETCH NEXT FROM C2 INTO @DeleteTableStatement
- WHILE @@FETCH_STATUS = 0
- BEGIN
- PRINT 'Executing ' + @DeleteTableStatement
- execute sp_executesql @DeleteTableStatement
- DBCC CHECKIDENT (@DeleteTableStatement, RESEED,1);
- FETCH NEXT FROM C2 INTO @DeleteTableStatement
- END
- CLOSE C2
- DEALLOCATE C2
Shahriar NikkhahPosted May 4, 2018, 8:48 PM
Nitin SontakkePosted May 3, 2018, 10:19 PM
Shahriar NikkhahPosted May 3, 2018, 9:12 PM