Posted on August 5, 2014 by sql_geek

Backup and Restore are the common tasks that a DBA needs to perform almost daily. In this blog I’ll talk about how to restore a transaction log in SQL Server. A …
Read More »
Posted on August 2, 2014 by sql_geek

Restore database SQL Server command with replace option is used when we need overwrite an existing database from a backup. The T-SQL command for same is shown below. RESTORE DATABASE [AdventureWorks2014] …
Read More »
Posted on July 23, 2014 by sql_geek
Many a times need arises to access/modify windows folder structures from SQL server. Though SQL Server is not meant for this purpose, however here is a T-SQL script to delete files …
Read More »
Posted on July 19, 2014 by sql_geek

This is an awesome feature where in one can restore transaction log point in time. A database can be restored to a specified using STOPAT option in restore command. Let’s look …
Read More »
Posted on July 10, 2014 by sql_geek

Many a times we need to find details about SQL server installation when inheriting a new environment or a setup. One way to figure it out is by reading a registry. …
Read More »
Posted on July 1, 2014 by sql_geek

Many a times we need to find all tables having a particular column in a database. Here is a T-SQL script to find column in database. SELECT DB_NAME(DB_ID()) As DatabaseName, OBJECT_SCHEMA_NAME(objects.object_id,db_id()) …
Read More »
Posted on June 25, 2014 by sql_geek

Many a times need arises to find all constraints on a table. A common use case is when dropping columns from a table we need to know the dependent objects so …
Read More »
Posted on June 24, 2014 by sql_geek

This blog briefs about using a simple cursor in SQL Server to insert records. This is not a real world complex example; however it will help you to understand to use …
Read More »
Posted on June 20, 2014 by sql_geek

A common task for DBAs/Developers is to find duplicates in tables to avoid redundancy and storage misuse. Here is a T-SQL script to find duplicates. Create table tblDup(Sno int identity, Col1 …
Read More »
Posted on June 17, 2014 by sql_geek

Many a times need arises to find objects a stored procedure depends on. The blogs describes a way to find dependencies of stored procedure in SQL server. The below query creates …
Read More »
Posted on June 8, 2014 by sql_geek

Many a times need arises to find all objects table depends on or is being referred. This blog will help you to find dependencies of a table in SQL Server. This …
Read More »
Posted on June 1, 2014 by sql_geek

Start SQL Server in single user mode command prompt is a must know task for any SQL server DBA. This can be either done via GUI by setting the startup parameters for …
Read More »
Posted on May 20, 2014 by sql_geek

Here is quick query to find stored procedure related to column in database. This comes handy when you have to alter/remove a particular column from a table and you need to …
Read More »
Posted on May 15, 2014 by sql_geek

Many a times need arises to find all stored procedures related to a table in the database. The below queries come handy then. -- Query 1 SELECT DISTINCT objects.name, objects.type, comments.text …
Read More »
Posted on May 10, 2014 by sql_geek
Every now and then questions come up forums asking about how to truncate log file in SQL Server. Truncating a transaction log file means clearing out space in the log file. …
Read More »
Posted on May 3, 2014 by sql_geek

Here is quick SQL function to convert list to table. -- sql function to convert list to table CREATE FUNCTION fn_listtotable ( @list nvarchar(max), @delimeter nvarchar(100) ) RETURNS @split TABLE ( …
Read More »
Posted on April 17, 2014 by sql_geek

Many a times need arises to create comma delimited list in SQL Server. This can be done using the DOR XML PATH feature of SQL Server. The FOR XML PATH generates …
Read More »
Posted on April 14, 2014 by sql_geek
Re indexing database tables in SQL server is a very wide topic. Ideally, we have database maintenance tasks scheduled to run during maintenance window to rebuild indexes along with other maintenance …
Read More »
Posted on April 10, 2014 by sql_geek

The SQL Server error 15023 User already exists in current database occurs when a databases is restored from another instance. The database users aren’t mapped to the corresponding logins at the …
Read More »
Posted on April 6, 2014 by sql_geek

Here is a way to restore database backup using SQL script. The first step is to get the logical file names contained in the backup device. -- get file names from …
Read More »
« Newer Entries
One Comment on “SQL Server Accidental DBA”