CORRUPTION 101

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 →

COOL T-SQL BACKUP/RESTORE QUERIES

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 →

SQL Journals

SQL Journals allows all SQL folks and other curious enthusiasts to post questions, concerns, experiences, and more. I am actively checking my journal and would promptly respond.  

Create a website or blog at WordPress.com

Up ↑