日期:2014-05-17  浏览次数:20768 次

各位高手帮忙,初学的菜鸟
创建一个school的表
schoolID schoolNAME NO.
  1 计算机 3
  2 外国语 2
  3 化工 1
  4 医学院 4
(主键)

要求:调整NO.的序号 1置顶  
  2置底
  3交换
  4上移
  5下移
  6移至
写一存储过程

------解决方案--------------------
先写一置顶的:


SQL code

create proc SetTop
@schoolID as int
as 
UPDATE SCHOOL SET A.[NO.]=B.[SN] FROM SCHOOL A JOIN 
(SELECT *,ROW_NUMBER() SN FROM (
SELECT * FROM SCHOOL WHERE schoolID =@schoolID 
UNION ALL 
SELECT * FROM SCHOOL WHERE SCHOOLID<> @SCHOOLID ORDER BY [NO.])C)B 
ON A.SCHOOLID=B.SCHOOLID

------解决方案--------------------
没看懂什么意思,帮顶.
------解决方案--------------------
1置顶
2置底
3交换
4上移
5下移
6移至
??

不懂...
------解决方案--------------------
这个存储过程情况比较多
探讨
先写一置顶的:



SQL code

create proc SetTop
@schoolID as int
as
UPDATE SCHOOL SET A.[NO.]=B.[SN] FROM SCHOOL A JOIN
(SELECT *,ROW_NUMBER() SN FROM (
SELECT * FROM SCHOOL WHERE schoolID =@scho……

------解决方案--------------------