четверг, 22 января 2015 г.

T-SQL Tricks - Part 2

Hi visitors,
Just in case: how can someone to use MS SQL Server 2000 system functions inside of UDF? The BOL says 'NO'. MS SQL 2008 restricts UDF but less.
But we will go further then plain 'no' and 'may be' and make almost ANY system function available in your UDF:

--The UDF:
CREATE FUNCTION dbo.fnSysGetAge(@dtBirthDate as datetime)
RETURNS int
AS
BEGIN
    DECLARE @intAge int, @dtGetDate datetime
    IF ISNULL(@dtBirthDate,0)<>0
    BEGIN
        SELECT  TOP 1 @dtGetDate = FunctionValue FROM vwSysFunctionValue WHERE FunctionName = 'GETDATE()'
        SET @intAge = ROUND(CONVERT(int, @dtGetDate - @dtBirthDate) / 365,0)
    END
    ELSE
        SET @intAge = 0
   
    RETURN @intAge
END
GO

--The view:
CREATE VIEW dbo.vwSysFunctionValue
AS
SELECT     CONVERT(nvarchar, GETDATE()) AS FunctionValue, 'GETDATE()' AS FunctionName
UNION
SELECT     CONVERT(nvarchar(20), RAND()) AS FunctionValue, 'RAND()' AS FunctionName
UNION
SELECT     CONVERT(nvarchar(20), dbo.fnSysGetCurrentUserOptionID()) AS FunctionValue, 'UserID()' AS FunctionName
GO
-------------
The same trick you can make with other system function - if they are available in views then they are available in your UDF!

среда, 9 июля 2014 г.

Investments In Corporate Software Technology

Did you ask yourself: "for how long time the XYZ company will be supporting our favorite ABC tool (technology)?" This is very interesting issue involving money and (more important!) time investments.

Let's say you choose the "platform" for it is "popular" and "easy to use". Popular - you can find qualified personnel NOW. "Easy to use" - you can build your 1-st beta product QUICKLY. Sounds good, right? But wait, didn't you see any pitfall there? The difficulties are everywhere in software life cycle and we should be aware of them ahead. On the picture with "popular and easy to use" ideas we ignored the word NOW. And we have forgot that we make real "money and time" investments in the future. OK then, what we should consider before we make our investments? The answer is: the future value of the chosen tools and platforms.

Lets see who uses two similar technologies: Microsoft.Net and Oracle Java. Both have robust tools and ecosystems. Both have fans and critics. But in real life large enterprises that love Microsoft Windows (for they depend on Windows apps) will choose Microsoft.Net (and rather C#) then Oracle Java. New small companies, city governments and Internet companies and startups will choose Oracle Java (or Open JDK) for 1) no license fees and 2) broadly set of free tools to build and test the software project. Besides feelings money meters. Who does support Microsoft.Net (and C#) now? It is clear that almost Microsoft (on Windows) and Xamarin (Microsoft.Net is partially supported on some operating systems). Also it is good to recall the facts that Microsoft killed tools like J#, old Visual Basic, Visual FoxPro. In contrast today Java is being supported by Oracle (uh!), IBM, Google (Android, GWT...), Apache foundation and by the large software community. You can see that Java has the clear future and it is very important for your investments. But can you give your own head for Microsoft.Net? I doubt. Yes, Java is under some pressure from other languages but Java API is open and fully portable (and Microsoft.Net?). And all that was said mean you can love Windows (or other OS and you corporate apps built for that OS) but better look at Java SDK for your new killing-feature corporate app, because Java powered software solutions have proved to have longer lasting life cycle and vendor - neutral technology.