Archive | SQL RSS feed for this section

Update consecutive numbering with UPDATE statement – MSSQL

I want to update a table with consecutive numbering starting at 1. The update has a where clause so only results that meet the clause will be renumbered. Can I accomplish this efficiently without using a temp table?

Read full story Comments { 0 }

What is – DML, DDL, DCL and TCL – Introduction

DML DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database. Examples: SELECT, UPDATE, INSERT statements DDL DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database. Examples: CREATE, ALTER, DROP statements DCL DCL is […]

Read full story Comments { 0 }

Find Duplicate Values with SQL Script

Let’s assume that data has been entered in a table and now you want to find if a table column have duplicated values. Here is an SQL script to join data from one table for comparison purpose. The table must have a primary key column (unique column) and the second column for comparison. Here is […]

Read full story Comments { 0 }

List all triggers in SQL Server database with table name and schema

Sample query: Here is and another version where you can the code of the trigger:

Read full story Comments { 0 }

T-SQL Script to Group Data by Minute

If you are doing a mass data insert into a table and you want to know how fast is inserting data. I have created a script that groups data by minute, based in a DateTime data type field.

Read full story Comments { 0 }

Converting UTC Time To Local Time in T-SQL – Sample

Sample 1: Sample with a table: Results (New York Time):

Read full story Comments { 0 }

T/SQL Splint String/Text

One common task performed in database applications is given a full name, how can this be split into the first name and last name.  In this article, three different methods are discussed to perform this task using three different functions in SQL Server.  It is assumed in this article that the full name is just […]

Read full story Comments { 0 }

Tips for Effective SQL Server Database Maintenance

“ I have been asked several times for advice on how to effectively maintain a production database. Sometimes the questions come from none-DBAs who are implementing new solutions and want help fine-tuning maintenance practices to fit their new databases’ characteristics. As with the majority of tasks and procedures in the IT world, there isn’t an easy […]

Read full story Comments { 0 }