views:

41

answers:

2

i have a large sql server db, and i want to get the schema (all tables/triggers/sprocs), i'm pretty sure that's easy.

but the tough part is that i want to get 100 records from each table. it's a huge db on a remote server and i can't develop locally without a mockup copy.

thanks for your help!

A: 

To get the schema, basically just select everything from the sys.objects catalog view:

SELECT * FROM sys.objects

For the data: you could use the undocumented (but extremely helpful) stored procedure sp_MSForEachTable for that purpose:

exec sp_MSforeachtable 'select top 100 * from ? '
marc_s
A: 

I would create a cursor with sys.objects to get the user defined tables and populate the new database with select query of top 100 rows.

Make sure you have (NOLOCK) hint to your query, so that it can avoid locks

Tamil.SQL