I have a table where some of the data are repeating. I need to copy the repeated values from the table to a new table.
Need an sql query to do this
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Adinarayana Reddy JcPosted May 8, 2015, 7:12 AM
try this one.
create table tbl_demo(Id int,Name varchar(50))
create table tbl_demo1(Id int,Name varchar(50))
insert into tbl_demo values(1,'adi')
insert into tbl_demo values(1,'adi')
insert into tbl_demo values(1,'adi')
insert into tbl_demo values(1,'ravi')
INSERT INTO tbl_demo1 SELECT Id,Name FROM tbl_demo GROUP BYId,Name HAVINGCOUNT(1) > 1