select count(*) from的问题
想要同是查询两个表的行数怎么写selectcount(*)ascount,count(*)ascount1fromtable1,table2这样不行,我试过了你的方法我也...
想要同是查询两个表的行数怎么写
select count(*) as count,count(*) as count1 from table1,table2
这样不行,我试过了
你的方法我也试过了,还是不行,得出的两个结果都是相同的,而且不对 展开
select count(*) as count,count(*) as count1 from table1,table2
这样不行,我试过了
你的方法我也试过了,还是不行,得出的两个结果都是相同的,而且不对 展开
2个回答
展开全部
一劳永逸的搞法
declare @tbl nvarchar(50)
Create table #tblSpace(
Name nvarchar(40),
Rows int,
reserved varchar(18),
Data varchar(18),
index_size varchar(18),
Unused varchar(18)
)
declare cur cursor for
Select name from sysobjects where xtype='U' and name='table1' or name = 'table2'
open cur
Fetch next from cur into @tbl
while @@fetch_status=0
begin
Insert into #tblSpace
EXEC sp_spaceused @tbl
Fetch next from cur into @tbl
end
close cur
deallocate cur
go
select name as 表名,rows as 行数 from #tblSpace
drop table #tblSpace
declare @tbl nvarchar(50)
Create table #tblSpace(
Name nvarchar(40),
Rows int,
reserved varchar(18),
Data varchar(18),
index_size varchar(18),
Unused varchar(18)
)
declare cur cursor for
Select name from sysobjects where xtype='U' and name='table1' or name = 'table2'
open cur
Fetch next from cur into @tbl
while @@fetch_status=0
begin
Insert into #tblSpace
EXEC sp_spaceused @tbl
Fetch next from cur into @tbl
end
close cur
deallocate cur
go
select name as 表名,rows as 行数 from #tblSpace
drop table #tblSpace
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询