SQL中没有记录号的概念,无法直接取得记录号,只有用下列方法!
Select RecordID=identity(int,1,1),* into #tt from table1
Select * from #tt
Drop table #tt
Select RecordID=identity(int,1,1),* into #tt from table1
Select * from #tt
Drop table #tt
解决方案 »
- sql创建表时在表名中可否加参数?怎么操作?
- 问下存储过程里的这段代码啥意思
- 对已建立好的表增加约束
- 如何将char转换成uniqueidentifier类型?
- SQL SERVER 2008 只能让A表可读
- win 2003 x64下安装sql2008 X64,但SQL带的Visual Studio 2008为什么装的是X86目录下那不就是32位吗?
- 两表连接查询的问题,在线等,求速度,急!!!
- sql6.5下执行一存储过程(其中包含有事务),出现如下错误信息,应该如何处理?谢谢!!
- 关于动态执行公式的方法
- 如何得到 所选数据的 条数 并得到这个值 付给 一个字符串??????
- 存储过程在线加分
- 在 select * from 语句中表名能否用变量名(存储过程中)
create proc p_qry
@n int=5,
@m int=7
as
select *
from [table] a
where (
select count(distinct score) from [table]
where score>=a.score
)between @n and @m
什么意思
不好吗?
select *,count(*)+1 排名 from table a join table b on a.id列=b.id列 where a.排名列<b.排名列 and (该记录的选择条件)降序排名
select *,count(*)+1 排名 from table a join table b on a.id列=b.id列 where a.排名列>b.排名列 and (该记录的选择条件)
if object_id('tbl_t') is null
print 'not exists'
else
drop table tbl_t
create table tbl_t
(
aa varchar(20),
bb varchar(20)
)insert into tbl_t values('a1','b1')
insert into tbl_t values('a2','b2')
insert into tbl_t values('a3','b3')
insert into tbl_t values('a4','b4')
select * from (select tmpid=identity(int,1,1),* into #tmp from tbl_t)t
select tmpid 行号 from #tmp where aa='a4'--删除表
drop table tbl_t
--结果:
/*
tmpid
-----------
4(所影响的行数为 1 行)
*/
--->
select tmpid=identity(int,1,1),* into #tmp from tbl_t
adodc1.recordset.movefirst
if adodc1.recordset.fields(0).value=a then
i=1
debug.printf a
else
adodc1.recordset.movenext
i=i+1
debug.printf a
endif