May 23, 2015

How to Check Database Integrity in SQL

Check Database Integrity for All Databases of Server

-- Single Database -- Use (?) for all the Database.

EXEC sp_msforeachdb 'DBCC CHECKDB(''DB_Name'')'

-- SQL 2005

EXEC sp_MSforeachDB 'DBCC CHECKDB (?) WITH ALL_ERRORMSGS, DATA_PURITY'

-- SQL 2008 and later

EXEC sp_MSforeachDB 'DBCC CHECKDB (?) WITH ALL_ERRORMSGS, EXTENDED_LOGICAL_CHECKS, DATA_PURITY'

Types of Testing Phases - DIT - SIT & UAT

Abbreviations of testing phases

DIT means - Development Independent Testing
SIT means - System Independent/Integration Testing
UAT means - User Acceptance Testing

A Simple Trick to Combined Multiple .SQL files into One Single File

Do the following task to combine all the *.sql files into one sql file

Files within the folder:

type *.sql > OneFile.sql

Multiple Files in Multiple Folder:


type e:\Folder1\*.sql e:\Folder1\Folder2\*.sql > e:\Folder1\final.sql