This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
Gouache painting of a strand of wooden beads above three small rings of beads, the middle ring holding one vermilion bead

Convert Integer to Date in SQL Server: ddMMyyyy Values

December 9, 2020
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts

To convert integer to date values such as 09122020, split the number into day, month and year and build the date from the parts. This post compares four methods on tested data, shows why a lost leading zero and the session language break two of them, and times them on a million rows.

Read More
Three vessels retain a supplied tag, an older tag and an empty tag loop.

SQL SERVER – Capturing INSERT Timestamp in Table

November 23, 2020
Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys, SQL DateTime, SQL Scripts, SQL Server

A default can insert timestamp values when the caller omits a datetime column. I use a session-local CURRENT_TIMESTAMP example.

Read More
statistics time

SET STATISTICS TIME ON – SQL in Sixty Seconds 139

October 27, 2020
Pinal Dave
SQL Video
SQL DateTime, SQL in Sixty Seconds, SQL Statistics

Do you know how long your query took to execution? Well, let us learn that today in SQL in Sixty Seconds. We will discuss SET STATISTICS TIME ON.

Read More
Gouache painting of six mugs in a row on a shelf in cream, slate blue, vermilion, sage and grey

Day Name From Date in SQL Server: DATENAME, FORMAT and More

July 27, 2020
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts

Finding the day name from date values takes one function, but three methods exist, and they differ on language and speed. This post compares DATENAME, FORMAT and a formula that ignores language and DATEFIRST. It measures all three on a million rows and shows how the session language changes the result.

Read More
Two complementary ceramic parts form one complete pouring vessel

How to Combine Time and Date in SQL SERVER? – Interview Question of the Week #285

July 12, 2020
Pinal Dave
SQL Interview Questions and Answers
SQL DateTime, SQL Function, SQL Scripts, SQL Server

Question: How to Combine Time and Date in SQL SERVER?

Answer: A very simple and popular question. Let us learn together.

Read More
A long-jump pit with a vermilion flag at last year's best mark and a fresh landing print just past it.

Year-Over-Year Comparisons in One Query

June 11, 2020
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Joins, SQL Reports, SQL Server

Build year-over-year monthly comparisons with a complete calendar, LAG, date-aligned joins, safe percentages, and missing-period rules.

Read More
A colorful paper chain along a kitchen window with one gap in the loops, scissors on the sill

A Daily Streak in SQL: Finding the Longest Run of Consecutive Days

October 29, 2019
Pinal Dave
SQL Tips and Tricks
Ranking Functions, SQL DateTime, SQL Scripts, SQL Server

Find consecutive days with gaps and islands, rank the longest streak per user, and define a current streak using the right business date.

Read More
Previous 1 2 3 4 5 6 7 … 29 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com