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

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

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

      1. <tfoot id='lLT1J'></tfoot>

        将 int 转换为 varchar

        Cast int to varchar(将 int 转换为 varchar)
        <tfoot id='4Jea4'></tfoot>
        • <legend id='4Jea4'><style id='4Jea4'><dir id='4Jea4'><q id='4Jea4'></q></dir></style></legend>

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

                1. 本文介绍了将 int 转换为 varchar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有以下查询,需要将 id 转换为 varchar

                  I have below query and need to cast id to varchar

                  架构

                  create table t9 (id int, name varchar (55));
                  insert into t9( id, name)values(2, 'bob');
                  

                  我尝试了什么

                  select CAST(id as VARCHAR(50)) as col1 from t9;
                  
                  select CONVERT(VARCHAR(50),id) as colI1 from t9;
                  

                  但它们不起作用.请提出建议.

                  but they don't work. Please suggest.

                  推荐答案

                  您需要castconvert 作为 CHAR 数据类型,没有可以将数据转换/转换为的 varchar 数据类型:

                  You will need to cast or convert as a CHAR datatype, there is no varchar datatype that you can cast/convert data to:

                  select CAST(id as CHAR(50)) as col1 
                  from t9;
                  
                  select CONVERT(id, CHAR(50)) as colI1 
                  from t9;
                  

                  在 SQL Fiddle 上查看以下 SQL — 实际操作:

                  See the following SQL — in action — over at SQL Fiddle:

                  /*! Build Schema */
                  create table t9 (id INT, name VARCHAR(55));
                  insert into t9 (id, name) values (2, 'bob');
                  
                  /*! SQL Queries */
                  select CAST(id as CHAR(50)) as col1 from t9;
                  select CONVERT(id, CHAR(50)) as colI1 from t9;
                  

                  除了您尝试转换为不正确的数据类型这一事实之外,您用于 convert 的语法也不正确.convert 函数使用以下内容,其中 expr 是您的列或值:

                  Besides the fact that you were trying to convert to an incorrect datatype, the syntax that you were using for convert was incorrect. The convert function uses the following where expr is your column or value:

                   CONVERT(expr,type)
                  

                   CONVERT(expr USING transcoding_name)
                  

                  您的原始查询的语法向后.

                  Your original query had the syntax backwards.

                  这篇关于将 int 转换为 varchar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Can#39;t Create Entity Data Model - using MySql and EF6(无法创建实体数据模型 - 使用 MySql 和 EF6)
                  MySQL select with CONCAT condition(MySQL选择与CONCAT条件)
                  Capitalize first letter of each word, in existing table(将现有表格中每个单词的首字母大写)
                  How to retrieve SQL result column value using column name in Python?(如何在 Python 中使用列名检索 SQL 结果列值?)
                  Update row with data from another row in the same table(使用同一表中另一行的数据更新行)
                  Exporting results of a Mysql query to excel?(将 Mysql 查询的结果导出到 excel?)

                    <small id='5txOB'></small><noframes id='5txOB'>

                  1. <legend id='5txOB'><style id='5txOB'><dir id='5txOB'><q id='5txOB'></q></dir></style></legend>

                    <tfoot id='5txOB'></tfoot>

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