T-SQL Code snippets

SQL Server T-SQL

Select top N records in T-SQL / SQL Server

In different databases, the syntax of selecting top N records are slightly different. They may also differ from ISO standards.

View detail
SQL Server T-SQL

Select from dual in T-SQL / SQL Server

In Oracle database, you can select from dual table if you only want to return a one row result set. In many other databases, the query engine supports select directly from constant values without specifying a table name. 

View detail
SQL Server T-SQL

Read and parse JSON in T-SQL / SQL Server

JSON is commonly used in modern applications for data storage and transfers. Pretty much all programming languages provide APIs to parse JSON. 

View detail
SQL Server T-SQL

Convert string to date in T-SQL / SQL Server

This code snippet shows how to convert string to date.

View detail
SQL Server T-SQL

Calculate time difference in T-SQL / SQL Server

This code snippet shows how to calculate time differences.

View detail