Decode() 对应 case when函数

case CHARINDEX('/',start_point_name)

when 0 then start_point_name

else substring(start_point_name,1,CHARINDEX('/',start_point_name)-1)

end

注意:sqlserver在用case when判断是否为null时,语法不一样

判断null应该用:

case when identifier is null then airway_point_name else identifier  end,

最简单的办法就是用isnll函数 isnull(idenfier, airway_point_name)

不行!isnull(idenfier, airway_point_name)会将idenfier缩短,本来5个字符,替换后只有4个字符,原因未知,最好不用isnull

instr对应CHARINDEX('/',start_point_name)函数,只不过两个参数的含义正好颠倒,也是从1开始计数

substr对应substring 参数完全一样,但长度参数不能缺少,不能默认到末尾,只能给一个足够大的长度值。

replace函数则完全一样

length函数对应 len函数

2016.7.10 SqlServer语句中类似decode、substr、instr、replace、length等函数的用法的更多相关文章

  1. sql语句中----删除表数据drop、truncate和delete的用法

    sql语句中----删除表数据drop.truncate和delete的用法 --drop drop table  tb   --tb表示数据表的名字,下同 删除内容和定义,释放空间.简单来说就是把整 ...

  2. MySQL中的insert ignore into, replace into等的一些用法小结(转)

    MySQL中的insert ignore into, replace into等的一些用法总结(转) 在MySQL中进行条件插入数据时,可能会用到以下语句,现小结一下.我们先建一个简单的表来作为测试: ...

  3. SQL中字符串截取、连接、替换等函数的用法

    一.SQL中SUBSTRING函数的用法1.功能:返回字符.二进制.文本或图像表达式的一部分2.语法:SUBSTRING ( expression, start, length )3.QL 中的 su ...

  4. php中print_r、var_dump和var_export几个函数的用法区别

    php中print_r.var_dump和var_export几个函数的用法区别

  5. Excel 数据导入至Sqlserver 数据库中 ltrim() 、rtrim() 、replace() 函数 依次空格无效问题

    今天导一些数据从Excel中至Sqlserver 数据库中,在做数据合并去重的时候发现,有两条数据一模一样,竟然没有进行合并: 最后发现有一条后面有个“空格”,正是因为这个“空格”让我抓狂许久,因为它 ...

  6. MySql查询语句中解决“该列没有包含在聚合函数或者groupby子句中”的相关问题方法

    首先引入语句来源,表结构和数据如下: 需求是:查出员工(personname)在不同店铺(store)的总薪酬(salary),相同店铺输出store,不同店铺输出multi_store. 正确查询语 ...

  7. mysql语句中----删除表数据drop、truncate和delete的用法

    程度从强到弱 1.drop  table tb        drop将表格直接删除,没有办法找回 2.truncate (table) tb       删除表中的所有数据,不能与where一起使用 ...

  8. 2019.6.13_SQL语句中----删除表数据drop、truncate和delete的用法

    一.SQL中的语法 1.drop table 表名称                         eg: drop table  dbo.Sys_Test   2.truncate table 表 ...

  9. sql语句中----删除表数据drop、truncate和delete的用法(转)

    转载于:http://www.cr173.com/html/40708_1.html 说到删除表数据的关键字,大家记得最多的可能就是delete了 然而我们做数据库开发,读取数据库数据.对另外的两兄弟 ...

随机推荐

  1. spring mvc 对象型参数的传递(遇到坑了)

    直接来个列子: 这里设置了,contenType="application/json" 这里post 接收的参数对象. 但是问题来了: <html> <head& ...

  2. [转载]allowTransparency属性

    原文地址:allowTransparency属性作者:惊寒唱晚 IE5.5开始支持浮动框架的内容透明.如果想要为浮动框架定义透明内容,则必须满足下列条件. 1.与 iframe 元素一起使用的 all ...

  3. Educational Codeforces Round 15 D. Road to Post Office 数学

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  4. Codeforces Round #304 (Div. 2) D. Soldier and Number Game 素数打表+质因数分解

    D. Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes input s ...

  5. UVA 10200 Prime Time 水

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  6. Python OS导入一个文件夹所有文件

    import os path = 'F:/save_file/seminarseries/' for root, dirs, files in os.walk(path): print(root) 这 ...

  7. Eclipse导出apk

    http://jingyan.baidu.com/article/7908e85c8dea30af491ad24f.html

  8. Springboot- pagehelper使用

    1.添加pagehelper依赖 <dependency> <groupId>org.github.pagehelper</groupId> <artifac ...

  9. jsp:jstl标签之控制流程

    下面将要讲的用于流程控制的标签,其中包括:if.choose.when 与 otherwise 等.接下来对这些标签逐一讲解. 这个标签的作用和 Java 程序中的 if 语句作用相同,用于判断条件语 ...

  10. hzau 1200 Choosy in Food

    1200: Choosy in Food Time Limit: 1 Sec  Memory Limit: 1280 MBSubmit: 32  Solved: 5[Submit][Status][W ...