Database Build Script

Database Folders Alter Alter sql scripts. Data Data sql scripts. DataTypes Data type sql scripts. DBScripts Create database sql scripts. ForeignKeys Foreign keys sql scripts. Functions Function sql scripts. Indexes Index sql scripts. PartitionFunctions Partition function sql scripts. PartitionSchemes Partition scheme sql scripts. Schemas Schema sql scripts. SQLJobs SQL job sql scripts. stbDDL Definition table... » read more

SSMS Tricks

Shortcuts Ctrl + C Copy Text Ctrl + V Paste Text Ctrl + X Cut Text Ctrl + A Select All Text Ctrl + W Select Word F5 Execute Query Ctrl + E Execute Query Ctrl + F Find Text Ctrl + H Replace Text Tab Increase Tab Shift + Tab Decrease Tab Ctrl +... » read more

Troubleshooting SQL Server

Log Files Job History Logs Database Server -> SQL Server Agent -> Job Activity Monitor -> Jobs -> View History SQL Server Logs Database Server -> Management -> SQL Server Logs Windows Event Viewer Windows -> Event Viewer

SQL Server Audits

Database Server -> Security -> Audits Database Server -> Security -> Server Audit Specifications Note: Make sure the audit file does not reach limit on 1) Number of Files 2) File Size Error 33206 – SQL Server Audit Failed to Create the Audit File SQL Server Audit failed to create the audit file ‘L:\ServerAudit\ServerAudit_EEFFB046-2AA7-4ACA-B91A-9F1FF5EF00EC.sqlaudit’. Make... » read more

Error 33206 – SQL Server Audit Failed to Create the Audit File

Error From Windows Event Viewer: SQL Server Audit failed to create the audit file ‘L:\ServerAudit\ServerAudit_EEFFB046-2AA7-4ACA-B91A-9F1FF5EF00EC.sqlaudit’. Make sure that the disk is not full and that the SQL Server service account has the required permissions to create and write to the file. Resolution: Change setting in the SQL Server Audit configuration or clear out files in... » read more

Database Fragmentation

The SQL Server Database Engine automatically modifies indexes whenever insert, update, or delete operations are made to the underlying data. Over time these modifications can cause the information in the index to become scattered in the database (fragmented). Fragmentation exists when indexes have pages in which the logical ordering, based on the key value, does... » read more

Index Rebuild vs Reorganize

The SQL Server Database Engine automatically modifies indexes whenever insert, update, or delete operations are made to the underlying data. Over time these modifications can cause the information in the index to become scattered in the database (fragmented). Fragmentation exists when indexes have pages in which the logical ordering, based on the key value, does... » read more

GETDATE() vs SYSDATETIME()

SYSDATETIME and SYSUTCDATETIME have more fractional seconds precision than GETDATE and GETUTCDATE.  Sources: https://docs.microsoft.com/en-us/sql/t-sql/functions/sysdatetime-transact-sql?view=sql-server-ver15

SQL Compare – Ignore Objects

SQL Compare Initial Setting Popup Window Crtl + E Options -> Ignore Ignore permissions Ignore system named constraint and index names Ignore SET QUOTED_IDENTIFIER and SET ANSI_NULLS statements Ignore users’ permissions and role memberships