MS SQL Tips & Tricks

Jacek Szarapa's MS SQL Library Version 1.0.0

Here you can download 1.0.0. version of SQL functions library. Library is meant to be free set of useful functions that can be used whatever you like. I'll try to add new functions as often as it is possible. If you feel like there is something, that is worth to be added here, just let me know.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either

Download SQL script

Version 1.0.0 includes:

String Functions
 
StringSplitToTable Converts delimited string into a table
 
StringPadLeft Pads given string with a specified character from left side
 
StringPadRight Pads given string with a specified character from right side
 
StringCountOccurrence Counts the occurences of specified string inside another string
 
DateTime Functions
 
FirstDayOfTheYear Returns the first day of year for given date
 
LastDayOfTheYear Returns the lest day of year for given date
 
FirstDayOfTheMonth Returns the first day of the month for given date
 
LastDayOfTheMonth Returns the last day of the month for given date
 
GetDatePart Returns the date part of datetime variable
 
GetTimePart Returns the time part of datetime variable
 
GetDayOfWeek Returns the day of week regardless @@DATEFIRST setting
 
GetCalendarWeekNo Returns the calendar week number regardless @@DATEFIRST setting
 
EncodeDate Returns the DateTime value of specifed Year, Month and Day
 
EncodeTime Returns the DateTime value of specifed Hour, Minute and Second
 
EncodeDateTime Returns the DateTime value of specifed Year, Month, Day, Hour, Minute and Second
 
ReplaceDatePart Replaces the date part the DateTime variable
 
ReplaceTimePart Replaces the time part the DateTime variable
 
DaysInYear Returns the numbers of days in a year of given datetime
 
DaysInAYear returns the numbers of days in a year
 
DaysInMonth returns the numbers of days in a month of given datetime
 
DaysInAMonth returns the numbers of days in a month
 
Yesterday returns the day before given date
 
Tomorrow returns the day after given date
 
IsToday returns if given date is a today's date
 
IsSameDay returns if given date is the same as the second one
 
Data Range Functions
 
GetDigits Returns the table with digits 0..9
 
GetNumbers100 Returns the table with numbers of given range but within boundaries of 0..100
 
GetNumbers1000 Returns the table with numbers of given range but within boundaries of 0..1000
 
GetNumbers10000 Returns the table with numbers of given range but within boundaries of 0..10000
 
GetNumbers100000 Returns the table with numbers of given range but within boundaries of 0..100000
 
GetDateRange Returns the table with days of given range but within boundaries of 0..1000 days.
 
GetDateRangeWithStep returns the table with days of given range but within boundaries 0..100000 records and specified interval
 
Download SQL script

See also


    Learn more tricks

    Add Comment

    Comments