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

边栏推荐
- 【招聘岗位】基础设施软件开发人员
- 爱可可AI前沿推介(7.5)
- maxcompute有没有能查询 表当前存储容量的大小(kb) 的sql?
- 729. My schedule I: "simulation" & "line segment tree (dynamic open point) &" block + bit operation (bucket Division) "
- Brief introduction of machine learning framework
- 超级哇塞的快排,你值得学会!
- Creation and use of thymeleaf template
- Install and configure Jenkins
- useMemo,memo,useRef等相关hooks详解
- 漫画:程序员不是修电脑的!
猜你喜欢
随机推荐
Photoshop插件-动作相关概念-ActionList-ActionDescriptor-ActionList-动作执行加载调用删除-PS插件开发
Using tensorboard to visualize the training process in pytoch
Creation and use of thymeleaf template
729. 我的日程安排表 I :「模拟」&「线段树(动态开点)」&「分块 + 位运算(分桶)」
长列表优化虚拟滚动
maxcompute有没有能查询 表当前存储容量的大小(kb) 的sql?
裁员下的上海
Selection and use of bceloss, crossentropyloss, sigmoid, etc. in pytorch classification
漫画:优秀的程序员具备哪些属性?
Live broadcast preview | how to implement Devops with automatic tools (welfare at the end of the article)
Crud de MySQL
P1451 求细胞数量/1329:【例8.2】细胞
CODING DevSecOps 助力金融企业跑出数字加速度
CPU设计实战-第四章实践任务二用阻塞技术解决相关引发的冲突
Install and configure Jenkins
用 Go 跑的更快:使用 Golang 为机器学习服务
Stm32+bh1750 photosensitive sensor obtains light intensity
Brief introduction of machine learning framework
Want to ask the big guy, is there any synchronization from Tencent cloud Mysql to other places? Binlog saved by Tencent cloud MySQL on cos
CPU design practice - Chapter 4 practical task 2 using blocking technology to solve conflicts caused by related problems









![[JVM] operation instruction](/img/f5/85580495474ef58eafbb421338e93f.png)