error in SQL String by CONCAT

  • 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

  • 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

  • Note CONCAT() is here since 2012 only. You are asking at wrong forum or trying to use what doesn't exist.

  • 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"

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply