Mostrando entradas con la etiqueta Database. Mostrar todas las entradas
Mostrando entradas con la etiqueta Database. Mostrar todas las entradas

Update SQLServer Identity Column


DECLARE @NewId INT = 23

DECLARE @TableName VARCHAR(MAX) = 'Database.Schema.TableName'

DBCC CHECKIDENT (@TableName, RESEED, @NewId)

 

Fix SQLServer Database marked as Suspect or Corrupted

ERROR: Database 'SenenDB' cannot be opened. It has been marked SUSPECT by recovery. See the SQL Server errorlog for more information. You can bring it online using the following steps:

--Reset the suspect flag
EXEC sp_resetstatus 'SenenDB'

--Set the database to emergency mode so that it becomes read only and not accessible to others
ALTER DATABASE SenenDB SET EMERGENCY

--Check the integrity among all the objects
DBCC CheckDB ('SenenDB')

--Set the database to single user mode
ALTER DATABASE SenenDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE

--Repair the errors
DBCC CheckDB ('SenenDB', REPAIR_ALLOW_DATA_LOSS)

--Set the database to multi user mode, so that it can now be accessed by others
ALTER DATABASE SenenDB SET MULTI_USER