SQLTeam.com | Weblogs | Forums

Allow PARSE To Be Used On SQL Server 2008 R2



Hi folks!

I'm hoping for some SQL wizardry workaround from y'all. My problem is as follows:

I have a Windows desktop application that users install on their systems. The install does normal install things, but most importantly it runs a SQL script that creates and populates a SQL Server database. Currently this works perfectly on SQL Server 2012 R2. One customer I am supporting would like it to work on SQL Server 2008 R2. I cannot edit my code due to some business reasons that I won't go into. My SQL script fails on 2008 because it uses the built-in PARSE function, which is only available on 2012. My SQL is similar to this (yes, this is somewhat contrived):

SET @MyInt = (SELECT (PARSE('99999' AS int)) + 50

What I would like to do is allow this to run on SQL Server 2008 R2. I tried creating a user-defined function named PARSE but that didn't work because a UDF needs to be specified using a schema name (e.g. dbo.PARSE).

Does anyone have any ideas how I can allow this to be installed on SQL SERVER 2008 R2?

Any help is greatly appreciated :slight_smile:


Even if you could get a function named PARSE() in 2008 R2, it would have to differ from 2012 since "as " is part of the syntax, they're not arguments. I don't believe a CLR function would support that, and T-SQL UDFs won't either.

If the client really needs that they'll have to upgrade to 2012 or higher. 2008 R2 is 6 years old and will soon be out of mainstream support from Microsoft (if not already).