0

I am trying to create a script for finding the row count for some tables in sybase ase. I have used the below --

set nocount on
go
set proc_return_status off
go
select count(*) from schemaname.tablename1
select count(*) from schemaname.tablename2
select count(*) from schemaname.tablename3
go

Now it gives me the output as below

456
768
321

What i want is to append a table name beside the count.Like below

456 tablename1
768 tablename2
321 tablename3

Please guide me on the same

Best Regards,

Debadtya

Mike Gardner
  • 6,611
  • 5
  • 24
  • 34

1 Answers1

1

Similar to what @aF wrote but a bit more refined.

select count(*) as rCount, 'tablename1' as tableName from tablename1
union
select count(*), 'tablename2' from tablename2
union
select count(*), 'tablename3' from tablename3
RobbZ
  • 1,410
  • 14
  • 19