Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Script to verify database now and after restore

Author  Topic 

kouliscon
Starting Member

7 Posts

Posted - 2011-08-02 : 06:56:30
Hello

I am doing backup of SQL to a network locaion and i need an sql command to return me the size of DB per table now, and then i will make a backup. Restore and run again the same sql command.

By that i verify that the backup and restore was succesfull.

DB is not in use by anyone.

thx


Kostas

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-02 : 07:36:13
do you mean split up of size based on tables?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

kouliscon
Starting Member

7 Posts

Posted - 2011-08-02 : 07:48:27
Hello
No i dont mean that.
DB1 is at server1.
I run BACKUP at a network location1.
I run sql script which returns that size of table1=1000rows, table2=2000rows....etc

I do restore i run script again.
i compare between 2 results.

just to be sure i want it.

thx

Kostas
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2011-08-02 : 08:05:01
This ?



declare @t table(TableName varchar(300),Count int)
insert @t
exec sp_msforeachtable 'select ''?'',count(*) from ?'

select * from @t order by TableName



PBUH

Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2011-08-02 : 12:19:13
There is also "exec sp_spaceused 'MyTable'" which would be faster though potentially less accurate. In a quiescent setting, such as you would find in the environment you describe, sp_spaceused should be accurate.

=======================================
I have never met a man so ignorant that I couldn't learn something from him. -Galileo Galilei, physicist and astronomer (1564-1642)
Go to Top of Page
   

- Advertisement -