首页 > 代码库 > 排序更改
排序更改
1 select p.Id,p.Title,g.* from testPager p 2 inner join pageQuestionGroup g on p.id=g.testPagerId 3 where publicDate is null 4 order by p.id,g.id 5 6 7 8 9 declare @testPagerId int10 set @testPagerId=3311 12 IF OBJECT_ID(‘dbo.#GroupQuestion‘,‘U‘) IS NOT NULL DROP TABLE dbo.#GroupQuestion;13 14 SELECT *15 INTO dbo.#GroupQuestion16 FROM GroupQuestion where testPagerId=@testPagerId17 order by id18 19 -- 声明变量20 DECLARE21 @id INT,22 @rank int23 set @rank=024 25 WHILE EXISTS(SELECT id FROM dbo.#GroupQuestion)26 BEGIN27 -- 也可以使用top 128 set @rank=@rank+129 SELECT top 1 @id=id FROM dbo.#GroupQuestion;30 UPDATE GroupQuestion SET sort=@rank WHERE id=@id; 31 DELETE FROM dbo.#GroupQuestion WHERE id=@id;32 END33 select * from dbo.#GroupQuestion34 DROP TABLE dbo.#GroupQuestion;
排序更改
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。