当前位置: 数据库>sqlserver
在查询结果中添加一列表示记录的行数的sql语句
来源: 互联网 发布时间:2014-09-05
本文导语: 代码如下: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 # ...
代码如下:
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 #