当前位置:网站首页>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(’’)

边栏推荐
- leetcode:881. lifeboat
- 手写promise与async await
- MongDB学习笔记
- qt creater断点调试程序详解
- [summary of leetcode weekly competition] the 81st fortnight competition of leetcode (6.25)
- IPv6与IPv4的区别 网信办等三部推进IPv6规模部署
- Handwriting promise and async await
- 【数组和进阶指针经典笔试题12道】这些题,满足你对数组和指针的所有幻想,come on !
- Two policemen were shot dead in a "safety accident" in Philadelphia, USA
- Is the securities account given by the head teacher of qiniu school safe? Can I open an account?
猜你喜欢

CPU设计相关笔记

Mongdb learning notes

计算中间件 Apache Linkis参数解读

How to paste the contents copied by the computer into mobaxterm? How to copy and paste

Creation and use of thymeleaf template

Machine learning notes - gray wolf optimization

Fr exercise topic --- comprehensive question

Implement a blog system -- using template engine technology

两个BI开发,3000多张报表?如何做的到?

Dark horse programmer - software testing -10 stage 2-linux and database -44-57 why learn database, description of database classification relational database, description of Navicat operation data, de
随机推荐
MongDB学习笔记
Run faster with go: use golang to serve machine learning
STM32+BH1750光敏传感器获取光照强度
easyOCR 字符识别
MySQL之CRUD
Reconnaissance des caractères easycr
注意!软件供应链安全挑战持续升级
【数组和进阶指针经典笔试题12道】这些题,满足你对数组和指针的所有幻想,come on !
[recruitment position] Software Engineer (full stack) - public safety direction
【jvm】运算指令
Fr exercise topic - simple question
Live broadcast preview | how to implement Devops with automatic tools (welfare at the end of the article)
Topology visual drawing engine
maxcompute有没有能查询 表当前存储容量的大小(kb) 的sql?
Talking about how dataset and dataloader call when loading data__ getitem__ () function
How to choose the appropriate certificate brand when applying for code signing certificate?
Interpretation of Apache linkage parameters in computing middleware
Creation and use of thymeleaf template
【C 题集】of Ⅷ
Crud de MySQL