1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

Some useful MS SQL functions

Discussion in 'SQL - Repository' started by ergen, Sep 1, 2009.

  1. ergen New Member

    Here you can find library of useful MS SQL functions. You are allowed to use the free.

    Jacek Szarapa - MS SQL Tips & Tricks - Jacek Szarapa's MS SQL Library Version 1.0.0


    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.

Share This Page