how to return table on sql function
The table-valued function requires static columns (names and types). If you want dynamic columns in result-set, use procedure instead of function.

E.G.

Create Procedure X(@tables varchar(50)) as
     DECLARE @colId int, @sql nvarchar(max),@colName nvarchar(400), @ssql nvarchar(MAX)  


        DECLARE oCur CURSOR FOR 
            SELECT [name] AS colName, colId
               FROM syscolumns
            WHERE id = (SELECT id FROM sysobjects WHERE type = 'U' AND [Name] = @tables )
            and xtype = '56' 

            SET @ssql = ''

            OPEN oCur

            FETCH NEXT FROM oCur INTO @colName, @colId
            WHILE @@FETCH_STATUS = 0
            BEGIN
                SET @ssql = @ssql + ' [' +@colname + '] is null or [' +@colname + '] &lt; 0 or [' +@colname + ']&gt;1 or'
                FETCH NEXT FROM oCur INTO @colName, @colId
            END 

            SET @ssql =  left (@ssql,len(@ssql)-3)   
            set @sql = 'select * from '+@tables+' where ' + @ssql 
            exec(   @sql)

           close ocur;
        deallocate ocur;
GO
X 'Tree'