TempDB growing: Chronicles of a DBA

As a DBA, you would be faced with situations where databases would begin to grow exponentially causing issues like low disk space. One of the most common databases that is famous for growing is the almighty [TempDB]. TempDB is well known over the decades for being the major culprit for grow and filling up the... Continue Reading →


CORRUPTION TOOLKIT: BACKUP & RESTORE - See if the backup is clean once you restore (usually on another server. BCP (Bulk Copy) & DB ATTACH - try to BCP remove the corrupt tables and restore (attach) the remaining database REBUILD/REPAIR databases System database issues (corruption) - rebuild will replace system database then you can replace... Continue Reading →

T-SQL Pivot

To a large extent business users want to visualize data in a tabular format as shown below. This is a good presentation however, it takes 3 rows just to present data for CustomerID 11000 and 31406 rows to present data for all the CustomerIDs. What if your requirement is to represent each year as an individual... Continue Reading →

50 Frequently Asked SQL Server Interview Questions – Part I

How will you to performance tuning ? https://www.youtube.com/watch?v=P97_oFfD218 What will you look for in an execution plan ? http://www.mssqltips.com/sqlservertutorial/285/query-execution-plans/ What is bookmark look-up related to execution plan http://www.qdpma.com/CBO/s2kCBO_2a.html Table variables vs temp tables http://engineering.picscout.com/2012/04/ sql-temporary-tables-vs-table-variables_17.html How do you pass output parameter in a stored procedure... If you specify the OUTPUT keyword for a parameter in... Continue Reading →

Cool Maintenance T-SQL Scripts

How to run an integrity check on all databases DECLARE @SQL VARCHAR(1000) DECLARE @DB sysname DECLARE curDB CURSOR FORWARD_ONLY STATIC FOR SELECT [name] FROM master..sysdatabases WHERE [name] NOT IN ('tempdb') and DATABASEPROPERTYEX(name, 'Status') != 'OFFLINE' ORDER BY [name] OPEN curDB FETCH NEXT FROM curDB INTO @DB WHILE @@FETCH_STATUS = 0 BEGIN SELECT @SQL = 'USE... Continue Reading →


How to Restore Database from a Shared Network Location --Restore Database from a shared network location --Change N' as needed and database name USE [master] RESTORE DATABASE [Db_Test] FROM DISK = N'\\Server_Name\Folder_Name\db_test.bak' WITH FILE = 1, MOVE N'DB_Test' TO N'F:\SQLData\Folder_Name\db_test.mdf', MOVE N'DB_Test_log' TO N'F:\SQLLogs\Folder_Name\db_test_log.LDF', NOUNLOAD, STATS = 5 GO   How to get Database Restore... Continue Reading →

How to change SQL Server Instance Collation in an Always On Environment.

SUMMARY You have successfully installed and configured a 2-Node Cluster with Always On which has been deployed into Production. Well you notice later that your 2 SQL Server Standalones participating in your AlwaysOn have different Server Collation. Assuming: Server A: Latin1_General_CI_AS - Case Insensitive Server B: SQL_Latin1_General_CP1_CI_AS ACTION We are instructed as DBA's to get... Continue Reading →

Create a website or blog at WordPress.com

Up ↑