简介 merge join 对两个表在连接列上按照相同的规则排序,然后再做merge,匹配的输出. 下面这个动态图展示了merge join的详细过程. merge join示例 创建两个表 IF OBJECT_ID('dbo.Tbl10') IS NOT NULL DROP TABLE dbo.Tbl10; CREATE TABLE dbo.Tbl10( Id INT IDENTITY(1,1), Val INT, Fill CHAR(7000) NOT NULL DEFAULT REPLIC…
直接上代码 --top not in方式 select top 条数 * from tablename where Id not in (select top 条数*页数 Id from tablename) --ROW_NUMBER() OVER()方式 select * from ( select *, ROW_NUMBER() OVER(Order by Id ) AS RowNumber from tablename ) as b *条数 and 页数*条数 --offset fetch…
create function fun_A() #标题函数.create function fun_name() returns output_type as begin return value end;returns intasbegin return 1;endgo create function fun_B() #多语句用户定义函数.create function fun_name() returns @value table(colum_list) as begin return…
数据插入:INSERT INTO A(CBM,CMC) VALUES('1','测试')--单条数据插入INSERT INTO A(CBM,CMC)SELECT '1','测试'--单条数据插入INSERT INTO A(CBM,CMC)SELECT CBM,CMC FROM B--批量插入B中所有数据…