declare @row varchar(30)
declare @tbname varchar(30)
DECLARE string_find_cursor CURSOR FAST_FORWARD FOR
SELECT [name]
FROM sysobjects where type='U' and name like 'A%'
ORDER BY [name]
OPEN string_find_cursor
FETCH NEXT FROM string_find_cursor
INTO @tbname
WHILE @@FETCH_STATUS = 0
BEGIN
--select @row=count(*) from @tbname
select @row=rows from sysindexes where id = object_id(cast(@tbname as varchar(30))) and indid in (0,1)
if(cast(@row as int))>0
print @tbname+' '+@row+' '+'select * from '+@tbname
FETCH NEXT FROM string_find_cursor
INTO @tbname
END
CLOSE string_find_cursor
DEALLOCATE string_find_cursor