各位高手帮忙,初学的菜鸟
创建一个school的表
schoolID schoolNAME NO.
1 计算机 3
2 外国语 2
3 化工 1
4 医学院 4
(主键)
要求:调整NO.的序号 1置顶
2置底
3交换
4上移
5下移
6移至
写一存储过程
[解决办法]
先写一置顶的:
create proc SetTop@schoolID as intas 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移至
??
不懂...
[解决办法]
这个存储过程情况比较多