<small id='520KB'></small><noframes id='520KB'>

  • <tfoot id='520KB'></tfoot>
      <bdo id='520KB'></bdo><ul id='520KB'></ul>

      1. <legend id='520KB'><style id='520KB'><dir id='520KB'><q id='520KB'></q></dir></style></legend>
      2. <i id='520KB'><tr id='520KB'><dt id='520KB'><q id='520KB'><span id='520KB'><b id='520KB'><form id='520KB'><ins id='520KB'></ins><ul id='520KB'></ul><sub id='520KB'></sub></form><legend id='520KB'></legend><bdo id='520KB'><pre id='520KB'><center id='520KB'></center></pre></bdo></b><th id='520KB'></th></span></q></dt></tr></i><div id='520KB'><tfoot id='520KB'></tfoot><dl id='520KB'><fieldset id='520KB'></fieldset></dl></div>

        SQL Server 转换选择一列并将其转换为字符串

        时间:2023-10-08
      3. <tfoot id='rq6uV'></tfoot>

          <i id='rq6uV'><tr id='rq6uV'><dt id='rq6uV'><q id='rq6uV'><span id='rq6uV'><b id='rq6uV'><form id='rq6uV'><ins id='rq6uV'></ins><ul id='rq6uV'></ul><sub id='rq6uV'></sub></form><legend id='rq6uV'></legend><bdo id='rq6uV'><pre id='rq6uV'><center id='rq6uV'></center></pre></bdo></b><th id='rq6uV'></th></span></q></dt></tr></i><div id='rq6uV'><tfoot id='rq6uV'></tfoot><dl id='rq6uV'><fieldset id='rq6uV'></fieldset></dl></div>
          • <small id='rq6uV'></small><noframes id='rq6uV'>

            • <legend id='rq6uV'><style id='rq6uV'><dir id='rq6uV'><q id='rq6uV'></q></dir></style></legend>
                <tbody id='rq6uV'></tbody>
                <bdo id='rq6uV'></bdo><ul id='rq6uV'></ul>

                  本文介绍了SQL Server 转换选择一列并将其转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否可以编写一个语句,从表中选择一列并将结果转换为字符串?

                  Is it possible to write a statement that selects a column from a table and converts the results to a string?

                  理想情况下,我希望使用逗号分隔值.

                  Ideally I would want to have comma separated values.

                  例如,假设 SELECT 语句看起来像

                  For example, say that the SELECT statement looks something like

                  SELECT column
                  FROM table
                  WHERE column<10
                  

                  结果是带有值的列

                  |column|
                  --------
                  |  1   |
                  |  3   |
                  |  5   |
                  |  9   |
                  

                  我想要的结果是字符串 "1, 3, 5, 9"

                  I want as a result the string "1, 3, 5, 9"

                  推荐答案

                  你可以这样做:

                  小提琴演示

                  declare @results varchar(500)
                  
                  select @results = coalesce(@results + ',', '') +  convert(varchar(12),col)
                  from t
                  order by col
                  
                  select @results as results
                  
                  | RESULTS |
                  -----------
                  | 1,3,5,9 |
                  

                  这篇关于SQL Server 转换选择一列并将其转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:带有 WHERE SELECT 子查询错误的 MYSQL 更新 下一篇:在 SQL Server 中只用一个选择取倒数第二行?

                  相关文章

                    <small id='D8k8i'></small><noframes id='D8k8i'>

                      <bdo id='D8k8i'></bdo><ul id='D8k8i'></ul>

                    1. <i id='D8k8i'><tr id='D8k8i'><dt id='D8k8i'><q id='D8k8i'><span id='D8k8i'><b id='D8k8i'><form id='D8k8i'><ins id='D8k8i'></ins><ul id='D8k8i'></ul><sub id='D8k8i'></sub></form><legend id='D8k8i'></legend><bdo id='D8k8i'><pre id='D8k8i'><center id='D8k8i'></center></pre></bdo></b><th id='D8k8i'></th></span></q></dt></tr></i><div id='D8k8i'><tfoot id='D8k8i'></tfoot><dl id='D8k8i'><fieldset id='D8k8i'></fieldset></dl></div>
                      <tfoot id='D8k8i'></tfoot>

                      <legend id='D8k8i'><style id='D8k8i'><dir id='D8k8i'><q id='D8k8i'></q></dir></style></legend>