当前位置:网站首页>sql server学习笔记
sql server学习笔记
2022-07-05 14:49:00 【蓝天⊙白云】
- cast(lx as nvarchar) sqlserver 拼接字符串
- sql server中实现mysql的find_in_set函数
CHARINDEX(cast( {
} as nvarchar),ancestors) > 0
- 查询结果后插入另外一张表
INSERT INTO [dbo].[sys_role_menu_tmp] SELECT * FROM [dbo].[sys_role_menu];
- 在SQL Server中,不支持 Limit 语句,可以用以下方式解决。
虽然SQL Server不支持 Limit ,但是它支持 TOP。
(1)如果要查询上述结果中前6条记录,则相应的SQL语句是:
select top 6 id from tablename
(2)如果要查询上述结果中第 7 条到第 9 条记录,则相应的SQL语句是:
select top 3 id from tablename where id not in ( select top 6 id from tablename )
select top @pageSize id from tablename where id not in (
select top @offset id from tablename
)
如果要查 n-m之间的数据 第4行的数字是n-1,第一行的数字是m-n+1,从而实现分页。
5. 字符串拼接
MySQL 采用 concat () 函数,SQL Server 的字符串拼接采用 “+” 完成。
SQL Server:‘a’+‘b’
MySQL:concat (‘a’,‘b’)
6. 获取当前时间
Mysql:now()
SQL Server:getdate()
7. 日期加减
Mysql:date_add()
date_add (date,INTERVAL expr type)
例子:date_add( now(), INTERVAL -1 YEAR)
date_add( now(), INTERVAL 5 DAY)
SQL Server:dateadd()
dateadd (datepart,number,date)
例子:dateadd (yy, -1, getdate())
dateadd (day, 5, getdate())
8. cast() 函数
注意par均为转换的参数
Mysql: locate()
Sql server:charindex()字符串str包含的字符个数
MySQL: char_length (str)
SQL Server: len (str)和datalength (str)转换格式
null判断
字符串替换
Sql server:stuff()
Mysql:insert()mysql:group_concat()与sql server:for xml path(’’)
边栏推荐
- 【NVMe2.0b 14-9】NVMe SR-IOV
- 729. My schedule I: "simulation" & "line segment tree (dynamic open point) &" block + bit operation (bucket Division) "
- How can I quickly check whether there is an error after FreeSurfer runs Recon all—— Core command tail redirection
- 【招聘岗位】软件工程师(全栈)- 公共安全方向
- 1330:【例8.3】最少步数
- 【数组和进阶指针经典笔试题12道】这些题,满足你对数组和指针的所有幻想,come on !
- 黑马程序员-软件测试-10阶段2-linux和数据库-44-57为什么学习数据库,数据库分类关系型数据库的说明Navicat操作数据的说明,Navicat操作数据库连接说明,Navicat的基本使用,
- 做研究无人咨询、与学生不交心,UNC助理教授两年教职挣扎史
- 可视化任务编排&拖拉拽 | Scaleph 基于 Apache SeaTunnel的数据集成
- 开挖财上的证券账户可以吗?安全吗?
猜你喜欢
随机推荐
【华为机试真题详解】欢乐的周末
微帧科技荣获全球云计算大会“云鼎奖”!
爱可可AI前沿推介(7.5)
CODING DevSecOps 助力金融企业跑出数字加速度
webRTC SDP mslabel lable
实现一个博客系统----使用模板引擎技术
[12 classic written questions of array and advanced pointer] these questions meet all your illusions about array and pointer, come on!
IPv6与IPv4的区别 网信办等三部推进IPv6规模部署
【C 题集】of Ⅷ
有一个强大又好看的,赛过Typora,阿里开发的语雀编辑器
Anaconda uses China University of science and technology source
Two Bi development, more than 3000 reports? How to do it?
亿咖通科技通过ISO27001与ISO21434安全管理体系认证
漫画:优秀的程序员具备哪些属性?
Ctfshow web entry information collection
CPU设计实战-第四章实践任务二用阻塞技术解决相关引发的冲突
Change multiple file names with one click
Leetcode: Shortest Word Distance II
[recruitment position] infrastructure software developer
How to choose the appropriate certificate brand when applying for code signing certificate?