• You could try something like this:

    select 'select top 5 * from '+s.name+'.'+t.name+' where '+c.name+' NOT LIKE ''__'''
    from sys.schemas s
    INNER JOIN sys.tables t on s.schema_id=t.schema_id
    INNER JOIN sys.columns c on t.object_id=c.object_id
    where c.name = 'State'

    Or use the LEN() function that would ignore trailing spaces

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2