• Okay all, just got out of a meeting and went back to it. I think I have it all sorted except for one, tiny portion:

    , 'StorageLocation'

    = STUFF

    (

    (

    SELECT ','

    + COALESCE('Rm: ' + lbr2.Room, '')

    + COALESCE(', Cab: ' + ll2.fkCabinet, '')

    + COALESCE(', Bin: ' + CAST(DecryptByKey(ll2.Bin) AS varchar(20)), '')

    + COALESCE(', Box: ' + CAST(DecryptByKey(ll2.Box) AS varchar(20)), '')

    + COALESCE(', ' + CAST(DecryptByKey(ll2.StartColumn) AS varchar(2))

    + CAST(DecryptByKey(ll2.StartRow) AS varchar(2)), '')

    + COALESCE(' --> ' + CAST(DecryptByKey(ll2.EndColumn) AS varchar(2))

    + CAST(DecryptByKey(ll2.EndRow) AS varchar(2)), '')

    FROM

    dbo.tblLotLocation AS ll2

    INNER JOIN

    dbo.tblLocationBldgRoom AS lbr2 ON lbr2.pkLocationBldgRoomId = ll2.fkLocationBldgRoomId

    WHERE

    ll2.fkItemLotId = od.fkItemLotId

    ORDER BY

    pkLotLocationId

    FOR XML PATH(''),

    TYPE

    ).value('.','varchar(max)')

    ,1

    ,1

    ,''

    )

    This is the section I am a bit stuck on:

    ).value('.','varchar(max)')

    I have read that .value() is an XQury function that accepts an XML data type and converts it to SQL Server data type. Makes sense.

    From MSDN: value (XQuery, SQLType), where "XQuery - is the XQuery expression, a string literal, that retrieves data inside the XML instance" and "SQLType - Is the preferred SQL type."

    But what is the XQuery '.' literal actually doing? Can I *assume* that since an empty string is sent to FOR XML PATH('') no root node name is created, and that the '.' argument in the XQuery is just looking at the unnamed root for its data?

    Thanks.

    Kurt