SQL Server 2008 Express CONCAT() doesn't exist?

前端 未结 3 1593
借酒劲吻你
借酒劲吻你 2020-12-10 02:03

I\'m making switch from MySQL to SQL Server 2008 Express and can\'t seem to find a CONCAT()-esque function. I have two columns I\'m trying to combine into a string and find

相关标签:
3条回答
  • 2020-12-10 02:35

    You can use CONCAT in SQL 2008 (if you REALLY want) by wrapping in brackets

    {fn CONCAT(id1,id2)} AS combo1
    

    NOTE: CONCAT only takes two arguments, so you must nest them if you wish to concatenate more than two strings:

    {fn CONCAT(id1,{fn CONCAT(id2,id3)})} AS combo2
    
    0 讨论(0)
  • 2020-12-10 02:38

    CONCATdoesn't exist in SQL Server 2008, it is new since SQL Server 2012.

    You could use instead:

    select id1, id2, id1 +  ", " + id2 as combo1
    FROM db1
    group by combo1
    
    0 讨论(0)
  • 2020-12-10 02:46

    Maybe something like,

    SELECT DISTINCT id1, id2, id1 + ', ' + id2
    

    would that work?

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