SQLInsider Scripts

Technical Article

Make a time value from a given float value

  • Script

Clients asked me to show a more detailed and longer text which doesn't have to be edited. So I came up with the following solution/function.This function returns a varchar time value with a description containing how many days, hours and minutes. For example 100.25 returns :'100:15( 4 Days, 4 Hours, 15 Minutes )'.I hope somebody […]

You rated this post out of 5. Change rating

2007-07-04 (first published: )

109 reads

Technical Article

Random Number Generator

  • Script

Often the RAND() function is predictable based on the seed. This stored procedure generates a pretty good random integer because the seed itself is quite unpredictable. You can’t put this in a UDF since it is indeterminate due to the RAND and GETDATE() functions used.

You rated this post out of 5. Change rating

2006-09-15 (first published: )

593 reads

Technical Article

Get Foreign Key of all the tables for Sqlserver DB

  • Script

This script will create two views and select the data from the TableReferences view. This view will give list of all the foreignkeys of the selected database with its constraint name, the table name and column name(s) on which the constraint is created and the referencing table name and column name(s).

5 (2)

You rated this post out of 5. Change rating

2006-09-25 (first published: )

589 reads

Technical Article

get rich schema details of all or some tables

  • Script

to get information about tables+columns+primarykeys+foreignkeys+identity, i firstly used SQL server built-in INFORMATION_SCHEMA.xxx. however, my company have various DBAs and each of them owns objects. when using INFORMATION_SCHEMA.xxx, it retrieves data based on current login (version 2005 resolves this schema v.s. object owner problem already... yeah) , which bring me a great trouble. if you want […]

3 (2)

You rated this post out of 5. Change rating

2006-08-30 (first published: )

546 reads

Technical Article

Overcome BCP limitations for output to CSV file

  • Script

This is an example to overcome short comings when using BCP to create a 'proper' CSV file. The view vw_Customers_RAW is used in order to provide a method of creating the column heading row and to enclose columns with embedded comma with double quotes, which are not options in BCP. There are more generic methods […]

1 (1)

You rated this post out of 5. Change rating

2006-07-03 (first published: )

2,879 reads

Technical Article

MIME64 Encoder and Decoder written in T-SSQL

  • Script

Here is a MIME64 encoder function written entirely in T-SQL!© 2006 Peter Larsson, Developer Workshop, all rights reservedAs long as the copyright notice is visible within the function declarationand you include a note in the documentation of your system that thesefunctions are written by me, you may use these functions for free of charge.If you […]

5 (1)

You rated this post out of 5. Change rating

2006-11-09 (first published: )

996 reads

Technical Article

Parse a fixed length numeric value from a string

  • Script

Specifically, I needed to parse a zip code (5-digit) from a client comments fields where the number was in different positions such as "Customer 999999999 should be at zip code 99999" and "99999 zipcode" and "should be zip code 99999 phone 9999999999". My stored procedure first filters on a [Comments] field string that contains variations […]

You rated this post out of 5. Change rating

2006-11-08 (first published: )

491 reads

Blogs

SQL Saturday Boston 2024 Slides

By

Thanks to everyone that came to my talks. Slides are below. Best Practices for...

Small Data SF 2024

By

I can’t remember how I heard about Small Data SF 2024, but it caught...

A New Word: Moledro

By

moledro – n. a feeling of resonant connection with an author or artist you’ll...

Read the latest Blogs

Forums

7 sept, scheduled book

By philip.scott

Comments posted to this topic are about the item 7 sept, scheduled book

7 sept, schedlued article

By philip.scott

Comments posted to this topic are about the item 7 sept, schedlued article

6 sept, published book

By philip.scott

Comments posted to this topic are about the item 6 sept, published book

Visit the forum

Question of the Day

Azure Data Lake Storage Gen 2

Azure Data Lake Storage Gen 2 is built on ...?

See possible answers