Showing posts from November, 2011

Extract currency values from text with T-SQL

CREATE FUNCTION dbo.fnGetAmounts(@str nvarchar(max))
-- generate all possible starting positions ( 1 to len(@str))
WITH StartingPositions AS
SELECT 1 AS Position
SELECT Position+1
FROM StartingPositions
WHERE Position <= LEN(@str)
-- generate all possible lengths
, Lengths AS
SELECT 1 AS [Length]
SELECT [Length]+1
FROM Lengths
WHERE [Length] <= 15
-- a Cartesian product between StartingPositions and Lengths
-- if the substring is numeric then get it
,PossibleCombinations AS

WHEN ISNUMERIC(substring(@str,sp.Position,l.Length)) = 1
THEN substring(@str,sp.Position,l.Length)
ELSE null END as Number
FROM StartingPositions sp, Lengths l
WHERE sp.Pos…

The <link> saga on ASP .Net

Indeed, there is a saga. Since from the very beginning of my ASP .Net experiences I had to deal with the "CSS problem". This problem occurs when the referenced CSS is not loaded, because the relative path is not given right.

We place in the Master Page all the common html used in the website, including the links to the CSS files. Pages might be placed in different nested folders and because of this, the link to the CSS file needs to be adjusted with the relative prefixes. Since the link is placed in the Master Page and it is not known in advantage the website structure, the solution should solve the problem of how is the right prefix added to the CSS link.

HTML introduced Relative Uniform Resource Locators ( see [Page 11]) which actually solves this problem. Instead of writing the absolute paths (ie. ), it suffices to use the relative paths, like public/main.css. That RFC explains the algorithm of how the prefixes ( /, ./, ../, ../../ so o…