Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
SQL Server 2000/2005/2008, Express, Access, MySQL, Oracle
Record per tabella.
lunedì 25 luglio 2011 - 13.54
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
Elenco Tags
SQL Server 2008 R2
iif
Profilo
| Expert
713
messaggi | Data Invio:
lun 25 lug 2011 - 13:54
Ciao, vorrei conoscere il numero dei record per ogni tabella presente in un database, vi posto il codice:
USE [databeis]
GO
/****** Object: StoredProcedure [dbo].[QueryImpatto_SP] Script Date: 07/25/2011 13:46:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[QueryImpatto_SP]
AS
DECLARE @nometabella nvarchar(50);
DECLARE Cursore CURSOR FOR
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
OPEN Cursore;
FETCH NEXT FROM Cursore; --INTO @nometabella;
--WHILE @@FETCH_STATUS = 0
--BEGIN
SELECT + @nometabella as Tabella , COUNT(*) as Quanti FROM + @nometabella;
--END
CLOSE Cursore;
DEALLOCATE Cursore;
------------------------------------------------
Dimentico qualcosa?
Grazie.
boccia75
Profilo
| Junior Member
109
messaggi | Data Invio:
mar 26 lug 2011 - 09:35
Ti do' questa che utlizzo io ed è senza l'uso di cursori:
SELECT a.name "Tabella", b.rows "Record"
FROM sysobjects a, sysindexes b
WHERE a.id = b.id AND b.indid <= 1 AND a.type = 'U'
AND a.name <> 'dtproperties'
ORDER BY a.name
Ciao,
Luca
iif
Profilo
| Expert
713
messaggi | Data Invio:
mar 26 lug 2011 - 12:33
Grazie
iif
Profilo
| Expert
713
messaggi | Data Invio:
mar 26 lug 2011 - 12:36
Grazie, e se volessi avere anche gli indici?
boccia75
Profilo
| Junior Member
109
messaggi | Data Invio:
mar 26 lug 2011 - 14:21
Adesso controllo.
Eccomi, questa è la query:
SELECT getdate(),b.name,i.name,I.TYPE_DESC
from sys.indexes i,sys.tables b
where B.object_id = i.object_id
and I.TYPE_DESC<>'HEAP'
Ciao
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !