zoukankan
html css js c++ java
MSSQL编程笔记一初识函数
发现T-SQL还是可以像c语言的,只不过是在某些情况下。
一个十六进制转十进制的例子:
create function Hex_to_Dec(@Hex_num varchar(20)) returns int as begin declare @m int declare @return_value int set @m=1 set @return_value=0 while @m<=len(@Hex_num) begin set @return_value=@return_value+convert(int, ( case when substring(@Hex_num,@m,1)<='9' then substring(@Hex_num,@m,1) when substring(@Hex_num,@m,1)='A' then '10' when substring(@Hex_num,@m,1)='B' then '11' when substring(@Hex_num,@m,1)='C' then '12' when substring(@Hex_num,@m,1)='D' then '13' when substring(@Hex_num,@m,1)='E' then '14' when substring(@Hex_num,@m,1)='F' then '15' end ))*power(16,len(@Hex_num)-@m) set @m=@m+1 end return @return_value end
函数的写法跟c语言相似极了,只是吧几个关键字换了,在这里的case when语句,跟c语言的switch case很相似。麻烦的是每次变量赋值都要加set关键字,略蛋疼。
查看全文
相关阅读:
SQL Server 创建用户报错:消息 15023,级别 16,状态 1,第 1 行 用户、组或角色 'XXX' 在当前数据库中已存在。
Win10安装sqlserver2014打开显示黑色界面,mardown打开显示报错
Centos7磁盘超过2TB使用parted命令分区
Html5學習重點清單
jQuery源码学习扒一扒jQuery对象初使化
jQuery源码学习
算法排序之插入排序
算法排序之冒泡排序
Sublime Text 3 安装
css布局你该了解的
原文地址:https://www.cnblogs.com/xiepeixing/p/2583958.html
最新文章
iOS开发系列--Objective-C之KVC、KVO
iOS开发系列—Objective-C之内存管理
iOS开发系列--Objective-C之协议、代码块、分类
iOS开发系列--Objective-C之类和对象
iOS开发系列—Objective-C之基础概览
iOS开发系列--C语言之构造类型
iOS开发系列--C语言之存储方式和作用域
iOS开发系列--C语言之预处理
sqlserver中批量导出所有作业或链接脚本
zabbix忘记admin登录密码重置密码
热门文章
苹果ios系统无法通过RD Client连接win10服务器远程错误0x00001307
sqlserver数据库导出表结构和表数据生成创建表和insert语句
Proxmox VE登陆的时候提示没有有效的订阅You do not have a valid subscription for this server. Please visit www.proxmox.com to get a list of available options.
Proxmox VE中出现TASK ERROR: command 'apt-get update' failed: exit code 100的解决方法
SQLServer无法删除登录名 '******',因为该用户当前正处于登录状态。 (Microsoft SQL Server,错误: 15434)
GitHub下载克隆clone指定的分支tag代码
Centos7安装搭建NTP服务器和NTP客户端同步时间
Vmware ESXi日志文件存放目录地址
Centos7安装搭建FTP服务器(最简便方法)
centos下mysql授予权限提示ERROR 1133 (42000): Can't find any matching row in the user table
Copyright © 2011-2022 走看看