1.使用游标 declare @sql varchar(), @name varchar() declare my_cursor scroll cursor for select name from sysobjects where type = 'u' and name like 'jobs_%' open my_cursor fetch next from my_cursor into @name ) begin print 'processing ' + @name set @sql =…
在SQL SERVER中获取表中的第二条数据, 思路:先根据时间逆排序取出前2条数据作为一个临时表,再按顺时排序在临时表中取出第一条数据 sql语句如下: select top 1 * from(select top 2 * from NumberLog where UserName = '管理员' order by dateTime desc ) [table] order by dateTime asc…