当前位置:网站首页>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(’’)
边栏推荐
- 有一个强大又好看的,赛过Typora,阿里开发的语雀编辑器
- Creation and use of thymeleaf template
- Leetcode: Shortest Word Distance II
- 729. 我的日程安排表 I :「模拟」&「线段树(动态开点)」&「分块 + 位运算(分桶)」
- Visual task scheduling & drag and drop | scalph data integration based on Apache seatunnel
- 基于TI DRV10970驱动直流无刷电机
- STM32+BH1750光敏传感器获取光照强度
- 裁员下的上海
- CODING DevSecOps 助力金融企业跑出数字加速度
- [detailed explanation of Huawei machine test] character statistics and rearrangement
猜你喜欢
Crud of MySQL
Thymeleaf uses background custom tool classes to process text
Mysql---- function
Crud de MySQL
MySQL----函数
MySQL之CRUD
美团优选管理层变动:老将刘薇调岗,前阿里高管加盟
有一个强大又好看的,赛过Typora,阿里开发的语雀编辑器
P6183 [USACO10MAR] The Rock Game S
How to choose the appropriate certificate brand when applying for code signing certificate?
随机推荐
Ecotone technology has passed ISO27001 and iso21434 safety management system certification
PyTorch二分类时BCELoss,CrossEntropyLoss,Sigmoid等的选择和使用
Live broadcast preview | how to implement Devops with automatic tools (welfare at the end of the article)
anaconda使用中科大源
亿咖通科技通过ISO27001与ISO21434安全管理体系认证
Differences between IPv6 and IPv4 three departments including the office of network information technology promote IPv6 scale deployment
Un week - end heureux
微帧科技荣获全球云计算大会“云鼎奖”!
Coding devsecops helps financial enterprises run out of digital acceleration
Mysql---- function
Super wow fast row, you are worth learning!
通过npm 或者 yarn安装依赖时 报错 出现乱码解决方式
[recruitment position] infrastructure software developer
【华为机试真题详解】欢乐的周末
两个BI开发,3000多张报表?如何做的到?
js亮瞎你眼的日期选择器
【数组和进阶指针经典笔试题12道】这些题,满足你对数组和指针的所有幻想,come on !
I collect multiple Oracle tables at the same time. After collecting for a while, I will report that Oracle's OGA memory is exceeded. Have you encountered it?
How can I quickly check whether there is an error after FreeSurfer runs Recon all—— Core command tail redirection
be careful! Software supply chain security challenges continue to escalate