Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

p2mb2

Query para devolver varios counters....

Recommended Posts

p2mb2

Caros,

fica aqui uma duvida basica.... preciso de um stored procedure que me devolva os counts de várias tabelas...

CREATE PROCEDURE getCounters

AS

BEGIN

SET NOCOUNT ON;

SELECT COUNT(id_tabela1) from tabela1 as countTabela1

        SELECT COUNT(id_tabela2) from tabela2 as countTabela2

        SELECT COUNT(id_tabela3) from tabela3 as countTabela3

END

Mas queria isto na mesma linha... deve ser algo simples, mas eu em base de dados não tenho exp.

Abraço e agradecendo antecipadamente despeço-me ;)

Share this post


Link to post
Share on other sites
renafi

CREATE PROCEDURE getCounters
AS
BEGIN
   SET NOCOUNT ON;
select
   (SELECT COUNT(id_tabela1) from tabela1 as countTabela1) c1,
   (SELECT COUNT(id_tabela2) from tabela2 as countTabela2) c2,
   (SELECT COUNT(id_tabela3) from tabela3 as countTabela3) c3
END

Espero que tenha ajudado


Oracle Certified Professional - AdministraçãoOracle Certified Professional - Pl/sqlMCPD - Microsoft Certified Professional DeveloperMCTS - Microsoft Certified Technology Specialist

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.