当前位置:网站首页>sqlserver 字符串类型转换成小数或者整数类型
sqlserver 字符串类型转换成小数或者整数类型
2022-06-30 20:37:00 【※※冰馨※※】
在SQL Server中,将字符串的值转换为数值类型的值可以有三种方法。
1.使用cast()方法。
select cast('6.0' as decimal(6, 2)); -- 6.00
2.使用convert()方法。
select convert(decimal(6, 2), '100'); -- 100.00
3.使用与数值0相加的方法。
select '233' + 0; -- 233
以上三种方法在转换类型的时候都要格外注意被转换类型的值,因为可能会出现各种强制转换失败的问题,比如小数位数/格式不匹配造成的报错。
边栏推荐
- MySQL introduction, detailed installation steps and usage | dark horse programmer
- 左值引用和右值引用
- Gartner聚焦中国低代码发展 UniPro如何践行“差异化”
- 报错:Internal error XFS_WANT_CORRUPTED_GOTO at line 1635 of file fs/xfs/libxfs/xfs_alloc.c.
- 学习总结
- Study on lumiprobe dye NHS ester BDP FL NHS ester
- MySQL简介、详细安装步骤及使用 | 黑马程序员
- Web APIs 综合案例-Tab栏切换 丨黑马程序员
- 数据库 OLAP、OLTP是什么?相同和不同?适用场景
- 基于开源流批一体数据同步引擎ChunJun数据还原—DDL解析模块的实战分享
猜你喜欢

报错:Internal error XFS_WANT_CORRUPTED_GOTO at line 1635 of file fs/xfs/libxfs/xfs_alloc.c.

STL的基本组成部分

All the important spark summit features were released here last night (with ultra clear video attached)

By analyzing more than 7million R & D needs, it is found that these eight programming languages are the most needed by the industry

注册设备监理师难考吗,和监理工程师有什么关系?

微信小程序怎么实现圆心进度条

在线教育项目用户登录和注册

NLP paper lead reading | what about the degradation of text generation model? Simctg tells you the answer

Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing

Deflection lock / light lock / heavy lock lock is healthier. How to complete locking and unlocking
随机推荐
PHP获取Opcode及C源码
Web APIs 综合案例-Tab栏切换 丨黑马程序员
谈谈内联函数
数据库 OLAP、OLTP是什么?相同和不同?适用场景
No "history of blood and tears" in home office | community essay solicitation
Encoding type of Perl conversion file
Lumiprobe染料酰肼丨BDP FL 酰肼方案
Label Contrastive Coding based Graph Neural Network for Graph Classification
MySQL:SQL概述及数据库系统介绍 | 黑马程序员
How can I get the stock account opening discount link? In addition, is it safe to open a mobile account?
SQL必需掌握的100个重要知识点:创建和操纵表
AVL平衡二叉树(一) - 概念与C语言实现
A complete collection of vulnerability scanning tools. Mom doesn't have to worry that I won't find any more vulnerabilities
obsidian配合hugo的使用,让markdown本地编辑软件与在线化无缝衔接
Go语学习笔记 - gorm使用 - 数据库配置、表新增 | Web框架Gin(七)
C file pointer
SQL优化
Solve the problems of Devops landing in complex environment with various tools with full stack and full function solutions
Lvalue reference and lvalue reference
北京大学ACM Problems 1006:Biorhythms