在查询结果中添加一列表示记录的行数的sql语句

来源:这里教程网 时间:2026-02-28 06:35:46 作者:

如何在查询结果中添加一列表示记录的行数? 要求是增加一列显示行数

代码如下:

declare @table table ([values] varchar(10))
insert into @table select 'aaa'
union all select 'ccc'
union all select 'eee'
union all select 'ddd'
union all select 'bbb'
select [rowid] = identity (int, 1, 1), * into # from @table
select * from #
drop table #

相关推荐