SEQUENCE Syntax
START WITH [StarNumber]
INCREMENT BY [IncrementNumber];
SEQUENCE Example
START WITH 1
INCREMENT BY 1;
Tips, Design principles, Best practices...
I was struck with a database which is on suspect mode and need to recover it without any recent backups. I searched across the net and found these steps which are quite useful
Step 1:
Clear the suspect mode of the database using sp_resetstatus DatabaseName. This will clear the suspect flag and make the database available online
Step 2:
Change the database status to Emergency using the following command. Emergency mode allows you to access the databases as normal but with no consistency guarantee. This option also allows us to export the table data so that we can minimize the damage.
ALTER DATABASE DatabaseName
Step 3:
Restrict database to single user by changing the access mode as mentioned below
ALTER DATABASE DatabaseName
Step 4:
Run the CHECKDB command with “REPAIR_ALLOW_DATA_LOSS” option. This option should be tried as last option as it always behaves the way it is named. We are not sure of what data it removes.
DBCC CHECKDB (DatabaseName
There are some best (simple) practices which prevents us from such failures. Below are some of them
Analysis
I have created a table patient with 1 lakh records of different Organisations and populated 70% data with OwnerOrganisation value 10 and selected the record with OwnerOrganisation value ="6"
Normal Index
CREATE INDEX IX_OwnerOrganisation ON Patient(OwnerOrganisationUID)