January 22, 2015 at 2:26 am
hi
i have 2 table:
t1:
t1_idint
namenvarchar(10)
t2:
t2_idint
t1_idint
Sematnvarchar(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
January 22, 2015 at 2:37 am
CONCAT is the System function..no need to specify as dbo.CONCAT, if you specify like this ...the SQL will go search an object exists with CONCAT in your User Objects....
plz check below link for more info...
https://msdn.microsoft.com/en-us/library/hh231515.aspx
here is sample query for your requirement...
Select CONCAT(dbo.t1.FstName,' ',dbo.t2.LstName) from dbo.T1 join dbo.t2 on dbo.t1.Id=dbo.t2.Id
January 22, 2015 at 2:54 am
Note CONCAT() is here since 2012 only. You are asking at wrong forum or trying to use what doesn't exist.
January 22, 2015 at 4:34 am
Also, note: CONCAT() is not an aggregate function.
If you aim is concatenate string values from different rows to single string, google for "concatenate string FOR XML PATH"
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply