当前位置:网站首页>SQL Server learning notes
SQL Server learning notes
2022-07-05 15:09:00 【Blue sky ⊙ white clouds】
- cast(lx as nvarchar) sqlserver String concatenation
- sql server To realize mysql Of find_in_set function
CHARINDEX(cast( {
} as nvarchar),ancestors) > 0
- Insert another table after the query result
INSERT INTO [dbo].[sys_role_menu_tmp] SELECT * FROM [dbo].[sys_role_menu];
- stay SQL Server in , I won't support it Limit sentence , It can be solved in the following ways .
although SQL Server I won't support it Limit , But it supports TOP.
(1) If you want to query the top of the above results 6 Bar record , The corresponding SQL The sentence is :
select top 6 id from tablename
(2) If you want to query the above results 7 To the first article 9 Bar record , The corresponding SQL The sentence is :
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
)
If you want to check n-m Data between The first 4 The number of lines is n-1, The number in the first line is m-n+1, This enables paging .
5. String splicing
MySQL use concat () function ,SQL Server String splicing of adopts “+” complete .
SQL Server:‘a’+‘b’
MySQL:concat (‘a’,‘b’)
6. Get the current time
Mysql:now()
SQL Server:getdate()
7. Date addition and subtraction
Mysql:date_add()
date_add (date,INTERVAL expr type)
Example :date_add( now(), INTERVAL -1 YEAR)
date_add( now(), INTERVAL 5 DAY)
SQL Server:dateadd()
dateadd (datepart,number,date)
Example :dateadd (yy, -1, getdate())
dateadd (day, 5, getdate())
8. cast() function
Be careful par Are parameters of conversion 
Mysql: locate()
Sql server:charindex()
character string str Number of characters included
MySQL: char_length (str)
SQL Server: len (str) and datalength (str)Transformation format

null Judge

String substitution
Sql server:stuff()
Mysql:insert()
mysql:group_concat() And sql server:for xml path(’’)

边栏推荐
- js亮瞎你眼的日期选择器
- webRTC SDP mslabel lable
- R 熵权法计算权重及综合得分
- "Sequelae" of the withdrawal of community group purchase from the city
- MongDB学习笔记
- 社区团购撤城“后遗症”
- Garbage collection mechanism of PHP (theoretical questions of PHP interview)
- [12 classic written questions of array and advanced pointer] these questions meet all your illusions about array and pointer, come on!
- PHP high concurrency and large traffic solution (PHP interview theory question)
- Cartoon: programmers don't repair computers!
猜你喜欢
随机推荐
MySQL----函数
用 Go 跑的更快:使用 Golang 为机器学习服务
Ecotone technology has passed ISO27001 and iso21434 safety management system certification
Detailed explanation of QT creator breakpoint debugger
[recruitment position] infrastructure software developer
一键更改多个文件名字
Cartoon: programmers don't repair computers!
当代人的水焦虑:好水究竟在哪里?
Huiyuan, 30, is going to have a new owner
Un week - end heureux
webRTC SDP mslabel lable
[recruitment position] Software Engineer (full stack) - public safety direction
How to solve the problem of garbled code when installing dependency through NPM or yarn
Ctfshow web entry explosion
Redis distributed lock principle and its implementation with PHP (1)
Select sort and bubble sort
Under the crisis of enterprise development, is digital transformation the future savior of enterprises
P1451 calculate the number of cells / 1329: [example 8.2] cells
Stm32+bh1750 photosensitive sensor obtains light intensity
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


![1330: [example 8.3] minimum steps](/img/69/9cb13ac4f47979b498fa2254894ed1.gif)


![P6183 [USACO10MAR] The Rock Game S](/img/f4/d8c8763c27385d759d117b515fbf0f.png)


