TRY_CONVERT not recognized

  • Is there something I'm missing here?

    select @@version

    Microsoft SQL Server 2014 - 12.0.4213.0 (X64) ...

    SELECT TRY_CONVERT(datetime2, '12/31/2010') AS Result;

    Msg 195, Level 15, State 10, Line 64

    'TRY_CONVERT' is not a recognized built-in function name.

    The same function works in my 2012 instance, but not my 2014.

    --=Chuck

  • It was the compatibility level of the database. It was set to something too old. I switched databases and it worked without problem.

    --=cf

  • It possible to 2012 server...,

    SELECT TRY_CONVERT(datetime2, '12/31/2010') AS Result;

    select @@version

    Result...

    2010-12-31 00:00:00.0000000

    Microsoft SQL Server 2012 - 11.0.2100.60 (X64)

    Feb 10 2012 19:39:15

    Copyright (c) Microsoft Corporation

    Developer Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)

    Kindly check your version...,

  • I'd tried the function within a database that had been restored into 2014 from a 2008 instance, so the compatibility level (100) of that database was set too low. When I tried the function in another database on the same 2014 server, a database that had been created within that 2014 instance, it worked.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply