代码改变世界

随笔档案-2011年02月

游标的用法,记录一下,老是忘记。。。。真是年纪大了

2011-02-21 15:56 by Rainbow, 321 阅读, 收藏,
摘要: declare @autoid intdeclare @username varchar(50)declare @userpwd varchar(32)declare cursor1 cursor forselect autoid,username,userpwd from user_core_temp --这个有几列 你在游标赋值时就能给几个变量赋值open cursor1fetch next from cursor1 into @autoid,@username,@userpwd --对应刚刚出表中select出来的列while @@FETCH_STATUS=0 --游标打开成功begin 阅读全文

表中重复记录的一些常用脚本

2011-02-14 16:40 by Rainbow, 365 阅读, 收藏,
摘要: 数据库有个T_Item 表是用来存放玩家的道具的,GS的bug导致背包中同一个位置存在多个物品。首先应查找出同一个角色(RoleId)下,同一个背包位置(UIPOS)超过2条物品(DBID)的数据。(多个条件,网上大部分的例子多是一个条件)select uipos,COUNT(*) as cou,RoleID,MAX(dbid) as dbid from T_Item group by UIPos,RoleID having COUNT(uipos)>1将这些数据放到临时表中。select uipos,COUNT(*) as cou,RoleID,MAX(dbid) as dbid in 阅读全文