Select the first 3 rows of each table in a database Select the first 3 rows of each table in a database sql sql

Select the first 3 rows of each table in a database


Here you have:

DECLARE @sql VARCHAR(MAX)='';SELECT @sql=@sql+'SELECT TOP 3 * FROM '+'['+SCHEMA_NAME(schema_id)+'].['+name+']'+';'  FROM sys.tablesEXEC(@sql)


 exec sp_MSforeachtable 'select top 3 * from ?'