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

边栏推荐
- 1330:【例8.3】最少步数
- What are the domestic formal futures company platforms in 2022? How about founder metaphase? Is it safe and reliable?
- 【华为机试真题详解】欢乐的周末
- 浅谈Dataset和Dataloader在加载数据时如何调用到__getitem__()函数
- FR练习题目---简单题
- 注意!软件供应链安全挑战持续升级
- 启牛学堂班主任给的证券账户安全吗?能开户吗?
- 729. 我的日程安排表 I :「模拟」&「线段树(动态开点)」&「分块 + 位运算(分桶)」
- Leetcode: Shortest Word Distance II
- [C question set] of Ⅷ
猜你喜欢
随机推荐
Brief introduction of machine learning framework
【华为机试真题详解】欢乐的周末
我这边同时采集多个oracle表,采集一会以后,会报oracle的oga内存超出,大家有没有遇到的?
注意!软件供应链安全挑战持续升级
Explain Vue's plan to clean up keepalive cache in time
anaconda使用中科大源
GPS original coordinates to Baidu map coordinates (pure C code)
[recruitment position] Software Engineer (full stack) - public safety direction
Leetcode: Shortest Word Distance II
JMeter performance test: serveragent resource monitoring
easyOCR 字符识别
超级哇塞的快排,你值得学会!
【招聘岗位】软件工程师(全栈)- 公共安全方向
NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
美团优选管理层变动:老将刘薇调岗,前阿里高管加盟
IPv6与IPv4的区别 网信办等三部推进IPv6规模部署
手写promise与async await
Long list optimized virtual scrolling
Coding devsecops helps financial enterprises run out of digital acceleration







