TRY_CONVERT fails on SQL Server 2012

后端 未结 2 1635
后悔当初
后悔当初 2020-12-30 01:26

The following SQL statement fails on SQL Server 2012(SP1) 11.0.3401.0 Version

DECLARE @b VARCHAR(10) = \'12312.2\'
SELECT TRY_CONVERT(DECIMAL(10,2),@b)


        
相关标签:
2条回答
  • 2020-12-30 01:46

    Make sure that you have specified on which database you want to run the query on.

    use [Database_Name]
    go    
    >>>>query here <<<
    go
    

    In my case I had a number of different databases on the server with different compatibility levels.

    0 讨论(0)
  • 2020-12-30 01:48

    Check that the database compatibility level for the particular database you are using the function in is set to SQL Server 2012 (110) under properties/options/compatibility level for the database.

    0 讨论(0)
提交回复
热议问题