Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 806 Bytes

File metadata and controls

46 lines (30 loc) · 806 Bytes

mssql

Rebuilding indexes

ALTER TABLE <table_name> NOCHECK CONSTRAINT ALL;
ALTER INDEX ALL ON <table_name> DISABLE;
ALTER INDEX ALL ON <table_name> REBUILD;
ALTER TABLE <table_name> CHECK CONSTRAINT ALL;

How to turn IDENTITY_INSERT on and off using SQL Server

SET IDENTITY_INSERT sometableWithIdentity ON

INSERT sometableWithIdentity (IdentityColumn, col2, col3, ...)
VALUES (AnIdentityValue, col2value, col3value, ...)

SET IDENTITY_INSERT sometableWithIdentity OFF

Cannot drop database "databasename" because it is currently in use.

use master;
GO

ALTER DATABASE databasename SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

GO

Drop constraint

alter table tablename DROP CONSTRAINT constraint_name