• are you looking for something like this

    exec ('select @liststr = coalesce(@liststr+'+''''+','+''''+' ,'+''''+''''+') + quotename(column_name)

    from '+ @server + '.'+ @db+ '.information_schema.columns where table_name = '+ ''''+ @table+'''')