SQL-queried columns are converted to comma-separated strings

Source: Internet
Author: User
Tags first string

Select Top + FID,
Replace (Stuff (select distinct ', ' +substring (F_paez_spmc1,1,charindex (", F_PAEZ_SPMC1)) from Paez_t_xsxxxx where f_ PAEZ_SPDM like ' 1% '
and C.fid=fid
FOR XML Path (")), ("), ",", ",") as Cooknames
From Paez_t_xsxxxx C
GROUP BY C.fid

STUFF (character_expression, start, length, character_expression)
Parameters
character_expression
A character data expression. A character_expression can be a constant, a variable, a character column, or a binary data row.

Start
An integer value that specifies the start position of the delete and insert. If start or length is negative, an empty string is returned. If start is longer than the first character_expression, an empty string is returned. Start can be a bigint type.

Length
An integer that specifies the number of characters to delete. If length is longer than the first character_expression, it is removed up to the last character in the last character_expression. Length can be a bigint type.

return type
If Character_expression is a supported character data type, character data is returned. If character_expression is a supported binary data type, binary data is returned.

Note
If the start position or length value is negative, or if the start position is greater than the length of the first string, an empty string is returned. If the length to be deleted is greater than the length of the first string, the first character in the first string is deleted.
If the result value is greater than the maximum value supported by the return type, an error is generated.

SQL-queried columns are converted to comma-separated strings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.