当前位置:网站首页>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
以上三种方法在转换类型的时候都要格外注意被转换类型的值,因为可能会出现各种强制转换失败的问题,比如小数位数/格式不匹配造成的报错。
边栏推荐
猜你喜欢

Binary search tree (1) - concept and C language implementation

Implementation principle of PostgreSQL heap table storage engine

断点续传和下载原理分析

Lumiprobe dye hydrazide - BDP FL hydrazide solution

AVL balanced binary tree (I) - concept and C language implementation

片荒吗?不用下载直接在线免费看的资源来了!2022年收藏夹必须有它!

Maya House Modeling

1.微信小程序页面跳转方法总结;2. navigateTo堆栈到十层不跳转问题

B_QuRT_User_Guide(33)

PHP获取Opcode及C源码
随机推荐
Is it safe to open an account for online stock trading!?
树基本概念
Lumiprobe蛋白质定量丨QuDye 蛋白定量试剂盒
Lumiprobe biotin phosphimide (hydroxyproline) instructions
Common questions and answering skills of project manager interview
浅谈代码语言的魅力
开发技术-使用easyexcel导入文件(简单示例)
[1175. prime number arrangement]
Document contains & conditional competition
maya房子建模
coredns 修改upstream
Lumiprobe染料酰肼丨BDP FL 酰肼方案
阿里kube-eventer mysql sink简单使用记录
Lumiprobe dye hydrazide - BDP FL hydrazide solution
哈夫曼树(一)基本概念与C语言实现
Huffman tree (I) basic concept and C language implementation
MySQL简介、详细安装步骤及使用 | 黑马程序员
Lumiprobe cell biology - dia, instructions for lipophilic tracer
Scene 299
Game 81 biweekly