Log in | Register

SQL Server Accidental DBA Series Archives - SQL Server Blogs, Events, Webcasts, Videos, SQL Server learning & education SQL Server Accidental DBA Series Archives - SQL Server Blogs, Events, Webcasts, Videos, SQL Server learning & education

SQL Server Accidental DBA Series


SQL Server Accidental/Involuntary/Junior DBAs Series

SQL Server new query window shortcut

Shortcuts help you to do your work swiftly and with increased productivity. In this blog we’ll look at new query window shortcut every SQL Server geek should know


Window + R -> ssms.exe
Open SQL Server management studio

Open a new query window

Move among open query windows

Execute All or selected queries

Ctrl […]

SQL Server error message 3159

One of my friends working on SQL Server 2000 to 2005 faced following issue.

Msg 3159, Level 16, State 1, Line 1
The tail of the log for the database “databasename” has not been backed up.
Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose.

SQL function to get weekday – weekly calendar

In this blog post we’ll look at a way to list out all week days of a week a particular date belongs too. This can be even referred to as weekly calendar. This comes handy in reporting. A SQL function to get week days of particular date is given below

First, create the below function […]

Insert multiple rows using single Insert statement in SQL Server

This is a very basic problem sometimes newbies struggle with. I have seen developers writing 10 different insert statements to insert 10 rows in a table.  This can be simplified in multiple ways as shown below


Like us on FaceBook  |  Join the fastest growing SQL Server group on FaceBook

Follow me on Twitter |  Follow […]

Constraint to limit VARCHAR max character length in SQL Server

A business need may arise to limit a VARCHAR column to a certain length. Consider a scenario where in an application has a 10000 character limit for a column. The VARCHAR(max) is the suitable data type choice for this column. However a VARCHAR(max) column is not limited to 10000 characters. In that case we […]

SQL Server unattended installation 2014

SQL Server unattended installation or silent installation can be done using the configuration.ini file. The SQL Server installation GUI application saves the setup instructions in a configuration.ini file which it further uses to install selected options. The same file can be modified and passed as a parameter to setup.exe command to do a silent/unattended installation.

The […]

Primary Key and Unique Key difference in SQL Server

Primary and Unique Key both enforce uniqueness of columns on which they are defined. Then where do they differ? They differ in following way

–          A primary key doesn’t allow null value wherein a unique key allows one null value.

–          A primary keys purpose is to uniquely define a row in a table wherein unique […]

Locking hints SQL Server

Locking hints are used with SELECT/INSERTS/UPDATE/DELETE statements to enforce or change the default locking behavior.  Given below are some of the locking hints available in SQL Server


The ROWLOCK hint tells query optimizer to lock rows (KEY level locks) instead of taking PAGE or TABLE level locks when reading or modifying data. A row lock […]

Difference between UNION and UNION ALL in SQL Server

Difference between UNION and UNION ALL is one of the most asked interview question.

UNION and UNION ALL both combine result set from two or more queries into single result. The difference is that UNION ALL doesn’t remove duplicate rows from the combined result set.

The below snapshot demonstrates the use of UNION operator.

The UNION operator […]

Detach or take offline in SQL Server

Detach or take offline both causes a database to be inaccessible to users. The difference is that detach deletes database metadata from SQL Server i.e. database file information, status information and all the other details that we see in sys.databases view. On the other hand taking database offline retains database metadata in SQL server […]