T-SQL: Adding Leading Zeros with a Simple Scalar Function

We were creating a extract at work from T-SQL and new that the we would need to export data with leading zeros. The data was not stored in the database with those leading zero values. The solution, create a simple scalar function to dynamically add the zeros that could accept two parameters ( text , and total length).

The Function is rather simple takes the total length value passed by the user and then subtracts the Length of the the text value.

What would make this better?

  • Would have a default value for total length
  • Error checking to make sure the text supplied is not longer than the total length

Read more »

Share the joy

The Shack – Worth Reading

To borrow and paraphrase from the book, “It’s Complex in it’s simplicity”.  Excellent story of God, The Son and Holy Ghost as reveled to a tired and burdened father. It’s remarkable how the story is told. Regardless of  faith or belief , it’s worth reading.

Here is a sample: Read the Forward

read more

Share the joy

The Next Giant Leap For Mankind

Nasa and Mars from 60 Minutes

NASA is serious, very serious, about launching the most difficult mission ever attempted by the human race – putting an astronaut on Mars. The voyage will cover hundreds of millions of miles and take two-and-a-half years roundtrip. It sounds like science fiction.

read more

Share the joy

Instructables – Made a Post

The kids and I started a garden this year. Going all in we needed to start some seeds.. So we teamed up and built this Grow light. It’s all fired up for our ‘non-herb’ plants. Please kids use your powers for good!

I present to you …Tah-duh.. Bamboo Grow Light 3000 ( patent pending dealer has no incentives to retain..)

Share the joy

From Code Project : .NET and SMS Messages

The Author PooranPrasad has compiles a concise article on setting up SMS messaging for applications.

Full article Here.

Read more »

Share the joy

Adobe AIR Makes Its Way to Linux

Adobe announced today that the pre-release alpha version of AIR for Linux is available immediately on the Adobe Labs site. Adobe shipped the 1.0 version of AIR for Windows and Mac last month but was forced to delay the Linux release.

read more

Share the joy

Instructables – Firefox Pranks

FROM INSTRUCTABLES
Read the Firefox Pranks! instructable by clicking here.

Using add-ons in Firefox to enhance your experience is boring. For April Fools’ Day, lets make the experience a little more bizarre.

Since these add-ons were meant to be installed on a victim’s computer you’ll only need two things:

– a victim who uses Firefox as his or her regular browser
– access to the victim’s computer
Read more »

Share the joy

T-SQL Create a View for Report Date Ranges by Month

The below example gives prior and current month first and last day values.The code below dynamically formats the date to give you date range values for reporting:

[LFM-FirstDay] – First Day of thePrior Month or Last Full Month First Day,
[LFM-LastDay] – 11:59 PM of the last day of the prior month,
[CM-FirstDay] – Current Month First Day and
[CM-LastDay] – 11:59 PM of the last day of the Current month.

USE [dbofchoice]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [DBO].[ReportDates]
AS
/*
LFM = LAST FULL MONTH
CM = CURRENT MONTH
*/
SELECT
DATEADD(month, -1 ,DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0))
as [LFM-FirstDay]
,DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate()),0))
as [LFM-LastDay]
,DATEADD(mm, DATEDIFF(m,0,getdate()),0)
as [CM-FirstDay]
,DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())+1,0))
as [CM-LastDay]
GO

Share the joy

C# – Calculating Distance between Zipcodes

Calculating the distance between ZIP codes has become a common feature in search engines. For instance, if you’re searching for restaurants, a Web site will often allow you to enter a ZIP code and display all of the restaurants within X miles of that ZIP code. Here is one way application developers to implement a ZIP code distance calculator using the .NET Framework and C#.

This article uses a derivation of the Haversine formula to calculate the distance between ZIP codes. The Haversine formula is used to determine the distance between two points on a sphere – in this case the earth. While this isn’t 100 percent accurate due to the earth not being a perfect sphere, it is probably as close as you’re going to get without getting out the tape measure!

Author: Zach Smith
Find TechRepublic Article Here.

Formula for techrepublic for Zipcode calculation of distances

Download PDF and Code Here

Share the joy

How to Make Simple Computer Games

From Instructables.com.  Pretty good little posting on using a free download IDE to make a video game.  Find the post here.

Download the program from the same location or Here.

UPDATE: – Second Posting by author Here.

Share the joy