T SQL Date format convert function

Northwind is my favorite database for trying out sample T-SQL scripts because of its simplicity. Here is the full script you can just copy/paste and run in SSMS (for sql server) or SQL Developer (for oracle) to create Northwind database …

Northwind Database Creation Script for SQL Server and Oracle Read more »

T SQL Date format convert function

Just came across very interesting scenario where I had to consume JSON data in SQL Server. Yes I can write C#/VB.net code and load JSON to SQL Server and go from there but what if I have no expertise in …

Consuming JSON data in SQL Server and SSIS, convert JSON to XML Read more »

T SQL Date format convert function

If you ever try to update several millions of record in single Update statement then think several times because it can cause real pain. Disadvantage of single Update statement is … Its considered as single transaction and it doesn’t commit …

How to update large number of records in batch Read more »

T SQL Date format convert function

Here is reusable function which can be used to format SQL dateTime to any format like C# or VB.net DROP FUNCTION dbo.fnFormatDate GO CREATE FUNCTION dbo.fnFormatDate (@Datetime DATETIME, @FormatMask VARCHAR(100)) RETURNS VARCHAR(100) AS BEGIN DECLARE @StringDate VARCHAR(100) SET @StringDate = …

T-SQL Date Format Function – fnDateFormat like .net Read more »

T SQL Date format convert function

Consider scenario where you want to populate missing data from previous date when data was available. In the following example we want to populate price of orders from most recent previous date when price was available. create table #orderinfo ( …

How to backfill data using SQL – populate missing values from historical data Read more »