CONCAT在SQL字符串中的错误 [英] error in SQL string by CONCAT
问题描述
hi
i有2个表:
t1:
t1_id int
名称nvarchar(10)
t2:
t2_id int
t1_id int
Semat nvarchar(50)
然后我按照SQL命令编写
SELECT dbo.T1.t1_id,dbo.CONCAT(dbo.T2.product)AS产品
来自dbo.T1 INNER JOIN
dbo.T2 ON dbo.T1.t1_id = dbo.T2.t1_id
GROUP BY dbo.T1.t1_id
但是以下错误是所示。为什么?
消息4121,等级16,状态1,行1
无法找到列dbo或用户定义的函数或聚合dbo.CONCAT,或名称含糊不清。
谢谢
hi
i have 2 table:
t1:
t1_id int
name nvarchar(10)
t2:
t2_id int
t1_id int
Semat nvarchar(50)
then i write following SQL Command
SELECT dbo.T1.t1_id, dbo.CONCAT(dbo.T2.product) AS product
FROM dbo.T1 INNER JOIN
dbo.T2 ON dbo.T1.t1_id = dbo.T2.t1_id
GROUP BY dbo.T1.t1_id
but following error is be shown. why?
Msg 4121, Level 16, State 1, Line 1
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.CONCAT", or the name is ambiguous.
thanks
推荐答案
这几乎是因为你使用的是2008R2,这个聚合可以从2012年开始使用。参见: https://msdn.microsoft.com/en-us/library/hh231515.aspx [ ^ ]
仍然可以将其实现为支持CLR的扩展: https://msdn.microsoft.com/en-us/library/ms131056.aspx [ ^ ]。另一方面,还有其他方法可以获得相同的结果:https://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/ [ ^ ]
That is pretty much because you are using 2008R2, and this aggregate is available from 2012. See: https://msdn.microsoft.com/en-us/library/hh231515.aspx[^]
Still, you can implement it as CLR enabled extension: https://msdn.microsoft.com/en-us/library/ms131056.aspx[^]. On the other hand there are other methods to echive the same result: https://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/[^]
这篇关于CONCAT在SQL字符串中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!