Posts

Showing posts from November, 2011

Extract currency values from text with T-SQL

CREATE FUNCTION dbo.fnGetAmounts(@str nvarchar(max)) RETURNS TABLE AS RETURN ( -- generate all possible starting positions ( 1 to len(@str)) WITH StartingPositions AS ( SELECT 1 AS Position UNION ALL SELECT Position+1 FROM StartingPositions WHERE Position <= LEN(@str) ) -- generate all possible lengths , Lengths AS ( SELECT 1 AS [Length] UNION ALL 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 ( SELECT CASE WHEN ISNUMERIC(substring(@str,sp.Position,l.Length)) = 1 THEN substring(@str,sp.Position,l.Length) ELSE null END as Number ,sp.Position ,l.Length FROM StartingPositions sp, Lengths l

The <link> saga on ASP .Net

Image
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. http://www.mysite.com/public/main.css ), it suffices to use the relative paths, like public/main.css. That RFC explains the algorithm of how the prefixes ( /, ./, ../, ../../ so