Posts

Showing posts from November, 2010

Get all the dates between two dates in SQL Server

CREATE FUNCTION [dbo].[GetDatesInBetween](@FromDate DATETIME, @ToDate DATETIME, @IncludeWeekends BIT )

RETURNS @DateTable TABLE(DATE DATETIME)
AS
BEGIN
INSERT INTO @DateTable (DATE) VALUES (@FromDate)
WHILE @FromDate < @ToDate
BEGIN
SELECT @FromDate = DATEADD(D, 1, @FromDate)
IF @IncludeWeekends = 1
INSERT INTO @DateTable (DATE) VALUES (@FromDate)
ELSE IF DATENAME(dw, @FromDate) <> 'Thursday' AND DATENAME(dw, @FromDate) <> 'Friday'
INSERT INTO @DateTable (DATE) VALUES (@FromDate)
END
RETURN
END

Strip/Remove HTML from text in SQL Server

I used the below function, because HTML contents are not fully supported in crystal report.

Ref:
http://blog.sqlauthority.com/2007/06/16/sql-server-udf-user-defined-function-to-strip-html-parse-html-no-regular-expression/

http://lazycoders.blogspot.com/2007/06/stripping-html-from-text-in-sql-server.html


CREATE FUNCTION [dbo].[StripHTML]

(
@HTMLText varchar(MAX)
)
RETURNS varchar(MAX)
AS
BEGIN
DECLARE @Start int
DECLARE @End int
DECLARE @Length int
-- Replace the HTML entity & with the '&' character (this needs to be done first, as
-- '&' might be double encoded as '&')
SET @Start = CHARINDEX('&', @HTMLText)
SET @End = @Start + 4
SET @Length = (@End - @Start) + 1
WHILE (@Start > 0 AND @End > 0 AND @Length > 0) BEGIN
SET @HTMLText = STUFF(@HTMLText, @Start, @Length, '&')
SET @Start = CHARINDEX('&', @HTMLText)
SET @End = @Start + 4
SET @Length = (@End - @Start) + 1
END
-- Replace the HTML entity < with the '<' ch…

Sunitha Krishnan fights sex slavery

Chimamanda Ngozi Adichie : Novelist

When we reject the single story, when we realize that there is never a single story about any place, we regain a kind of paradise

A poem by my Father: A Bridge at Sun

From Dream to Reality


The horizon blushed crimson
The backwaters sang lullaby
To the boats that rocked with the ripples
In the lake that bosomed the life around.

The island lay in the lap of the lake
Waiting for the night to fall over
The palm groves that glowed green
Grew darker against a painted sky.

A wistful dream of the islanders
For a bridge that would fill the chasm
To hug the city at random
Did come true at long last.

A bridge spanned across the lake
Like an arch that bade welcome
Fro all the sons and sisters of the island,
To the comforts and warmth of a home.

Life shall never be the same
Speed shall rule the roads
The waters that lulled the pace
Shall flow quiet beneath the bridge.

The darkness spreads across the waters
The city blinks open its umpteen eyes
The port, the boats and the ships
All glittered in the waves like a sea of stars..

An old man stood on the bank
A thousand sparks in his mind
Of the quiet journeys in the ferry
Of the beautiful sunsets he loved.

The br…

Martin Luther King "I have a dream"

We refuse to believe that the bank of justice is bankrupt.

Nineteen sixty-three is not an end, but a beginning.

Let us not seek to satisfy our thirst for freedom by drinking from the cup of bitterness and hatred.
We must forever conduct our struggle on the high plane of dignity and discipline.
We must not allow our creative protest to degenerate into physical violence.
Again and again, we must rise to the majestic heights of meeting physical force with soul force.

No, no, we are not satisfied, and we will not be satisfied until "justice rolls down like waters, and righteousness like a mighty stream."¹


And so even though we face the difficulties of today and tomorrow, I still have a dream. It is a dream deeply rooted in the American dream.

I have a dream that one day this nation will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident, that all men are created equal."

I have a dream that one day on the red hills of Georg…

C# code geneartor stored procedure

Ref: http://www.codeproject.com/KB/database/CSCodeBuilder.aspx

CREATE PROCEDURE tools_CS_SPROC_Builder



(


@objName nvarchar(100)


)


AS




SET NOCOUNT ON






DECLARE @parameterCount int


DECLARE @errMsg varchar(100)


DECLARE @parameterAt varchar(1)


DECLARE @connName varchar(100)


//Change the following variable to the name of your connection instance


SET @connName='conn.Connection'


SET @parameterAt=''






SELECT


dbo.sysobjects.name AS ObjName,


dbo.sysobjects.xtype AS ObjType,


dbo.syscolumns.name AS ColName,


dbo.syscolumns.colorder AS ColOrder,


dbo.syscolumns.length AS ColLen,


dbo.syscolumns.colstat AS ColKey,


dbo.systypes.xtype


INTO #t_obj


FROM


dbo.syscolumns INNER JOIN


dbo.sysobjects ON dbo.syscolumns.id = dbo.sysobjects.id INNER JOIN


dbo.systypes ON dbo.syscolumns.xtype = dbo.systypes.xtype


WHERE


(dbo.sysobjects.name = @objName)


AND


(dbo.systypes.status <> 1)


ORDER BY


dbo.sysobjects.name,


dbo.syscolumns.colorder



Visual Studio 2005 Crashing in Windows 7 randomly

faulting module craxddrt.dll_unloaded

The problem was that when opening my solution, by default it opened the last crystal report that i was working on. This seemed to start some crystal report ActiveX thing that didn’t work on Windows 7. It would always crash, even if i closed the report straight away.

To stop this problem was to load up VS, close the report immediately and safely close VS before it got a chance to crash! The next time it opens, there is no crystal report and the ActiveX control never loads.

So the next time you save the solution and close visual studio be sure to close all Crystal Reports window

Also I installed Service Pack for VS 2005, http://www.microsoft.com/downloads/en/details.aspx?FamilyID=90e2942d-3ad1-4873-a2ee-4acc0aace5b6&displaylang=en