USE [lysk2]
GO
/****** Object: StoredProcedure [dbo].[P_EvacuateNodes] Script Date: 2023/11/30 8:25:41 ******/
SET
ANSI_NULLS ON
GO
SET
QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[P_EvacuateNodes] @node int = 999 as begin truncate table CalStartTab;
EXEC P_CalculateStartProc @node;
truncate table CalEndTab;
EXEC P_CalculateEndProc @node;
truncate table EvacEvenNodesTab;
insert into
EvacEvenNodesTab
SELECT
tp.*
FROM
(
SELECT
TOP 100 PERCENT ROW_NUMBER() OVER (
partition BY ddid
ORDER BY
wtime
) AS rowNum,
sid,
tid,
ygid,
wtime,
ddid
FROM
WFRecord
WHERE
id IN (
SELECT
id
FROM
WFRecord wf
INNER JOIN CalStartTab s ON wf.ddid = s.ddid
INNER JOIN CalEndTab e ON wf.ddid = e.ddid
WHERE
(
sid = @node
OR tid = @node
)
AND wtime >= s.minTime
AND wtime <= e.maxTime
GROUP BY
wf.ddid,
wf.id
)
ORDER BY
wtime
) tp
WHERE
tp.rowNum % 2 = 0 truncate table EvacOddNodesTab;
insert into
EvacOddNodesTab
SELECT
tp.*
FROM
(
SELECT
TOP 100 PERCENT ROW_NUMBER() OVER (
partition BY ddid
ORDER BY
wtime
) AS rowNum,
sid,
tid,
ygid,
wtime,
ddid
FROM
WFRecord
WHERE
id IN (
SELECT
id
FROM
WFRecord wf
INNER JOIN CalStartTab s ON wf.ddid = s.ddid
INNER JOIN CalEndTab e ON wf.ddid = e.ddid
WHERE
(
sid = @node
OR tid = @node
)
AND wtime >= s.minTime
AND wtime <= e.maxTime
GROUP BY
wf.ddid,
wf.id
)
ORDER BY
wtime
) tp
WHERE
tp.rowNum % 2 = 1
end
突然翻到之前自己写的存储过程 现在看看都是头皮发麻 公司框架用的还是 .Net Framework 4.5
直接用 CYQ.Data 和数据库交互 sql 中 order by 还失效 必须先查询加载到内存后再排序
之前一直用的是 EF 或者 EF Core 也用过 SqlSugar 这样的第三方框架
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.