MS SQL Server View not allowing CONCAT

后端 未结 2 1749
死守一世寂寞
死守一世寂寞 2021-01-27 07:46

MS SQL Server 2014.

I have a SQL statement that works fine:

SELECT CONCAT (
        CAST(T1.[F1] AS INTEGER),
        CAST(T1.[F2] AS INTEGER)
        )          


        
2条回答
  •  情书的邮戳
    2021-01-27 08:28

    Don't use the visual designers.

    They are buggy and in this case convert

        SELECT CONCAT (
            CAST(T1.[F1] AS INTEGER),
            CAST(T1.[F2] AS INTEGER)
            ) AS F3 
    FROM mytable AS T1
    

    to

    SELECT { fn CONCAT(CAST(T1.F1 AS INTEGER), CAST(T1.F2 AS INTEGER)) } AS F3
    FROM     mytable AS T1
    

    Calling the highly limited ODBC escape sequence version of the function (that only accepts two parameters which must be strings)

    Just use a standard new query window to execute your CREATE VIEW/ALTER VIEW/SELECT FROM operations and you won't get this issue.

提交回复
热议问题