What I need is something like select * from table group by * having count(*) > 1
which doesn't work on mssql2008r2 and postgresql. The query runs a few times a week on different tables. The question has basically been posed before.
Because there has been confusion as to why someone would ever need this when there is DISTINCT: I need the query in order to identify identical rows in a table without primary key. I know this is not a regular case but this is exactly what I have to document and report.
Grouping by a subquery that returns all table columns and is formatted as a string doesn't work:
select * from table
group by (select column_name + ', ' as data() from information_schema.columns
where table_name = 'table' for xml path(''))
Return error msg. 144.
EDIT: When writing the query I don't know the column names. So I need a generic query without specifying the column names.
EDIT2: The proposed dynamic sql code works fine, but is not suited in my case, as it would be easier to create the GROUP BY String in my external code. So I'm still looking for a way to solve this with one query.