Click here to Skip to main content
15,887,135 members
Home / Discussions / Database
   

Database

 
AnswerRe: Student Grade and Grade Point Callculation Pin
Mycroft Holmes21-Nov-15 13:41
professionalMycroft Holmes21-Nov-15 13:41 
GeneralRe: Student Grade and Grade Point Callculation Pin
Aliyu Usman21-Nov-15 19:07
Aliyu Usman21-Nov-15 19:07 
GeneralRe: Student Grade and Grade Point Callculation Pin
Mycroft Holmes21-Nov-15 20:47
professionalMycroft Holmes21-Nov-15 20:47 
AnswerRe: Student Grade and Grade Point Callculation Pin
GuyThiebaut24-Nov-15 2:08
professionalGuyThiebaut24-Nov-15 2:08 
Questionnewtonsoft.json parser - how to deploy a CLR to SQL Server 2008 R2? Pin
Member 822518018-Nov-15 11:55
Member 822518018-Nov-15 11:55 
QuestionRemoval and delete of duplicate records in my table Pin
goldsoft15-Nov-15 2:37
goldsoft15-Nov-15 2:37 
AnswerRe: Removal and delete of duplicate records in my table Pin
Mycroft Holmes15-Nov-15 11:53
professionalMycroft Holmes15-Nov-15 11:53 
AnswerRe: Removal and delete of duplicate records in my table Pin
RNA Team15-Nov-15 16:00
RNA Team15-Nov-15 16:00 
Try this

SQL
CREATE TABLE tblTest (ID INT, NAME VARCHAR(20),AGE INT)
INSERT INTO tblTest VALUES(1,'AAA',22),(1,'AAA',22),(2,'BBB',33),(2,'BBB',33),(2,'BBB',33),(3,'CCC',44),(4,'DDD',55)

--create an alternate table to store the duplicate records
CREATE TABLE tblTestDuplicate (ID INT, NAME VARCHAR(20),AGE INT)

-- insert those duplicate records to this new table
INSERT INTO tblTestDuplicate
SELECT *
FROM tblTest
GROUP BY ID,NAME,AGE
HAVING COUNT(ID) > 1

--delete the duplicate records from the original table
DELETE FROM
tblTest 
WHERE  ID IN (SELECT ID FROM tblTestDuplicate)

--insert all the records into the original table
INSERT INTO tblTest
SELECT * 
FROM tblTestDuplicate

--Project the new records
SELECT *
FROM tblTest
ORDER BY ID


--clean up
DROP TABLE tblTestDuplicate
DROP TABLE tblTest


/*
SQL
ID	NAME	AGE
1	AAA	    22
2	BBB	    33
3	CCC	    44
4	DDD	    55

*/

Hope this helps

modified 15-Nov-15 23:11pm.

QuestionI need to get a count of records, including column Names grouped by UnitName. What am I doing wrong? Pin
samflex13-Nov-15 5:34
samflex13-Nov-15 5:34 
AnswerRe: I need to get a count of records, including column Names grouped by UnitName. What am I doing wrong? Pin
Mycroft Holmes13-Nov-15 13:56
professionalMycroft Holmes13-Nov-15 13:56 
AnswerRe: I need to get a count of records, including column Names grouped by UnitName. What am I doing wrong? Pin
RNA Team13-Nov-15 16:32
RNA Team13-Nov-15 16:32 
QuestionSQL Linq, better idea than a join for as enumerable Pin
jkirkerx11-Nov-15 9:09
professionaljkirkerx11-Nov-15 9:09 
AnswerRe: SQL Linq, better idea than a join for as enumerable Pin
Jörgen Andersson11-Nov-15 9:53
professionalJörgen Andersson11-Nov-15 9:53 
GeneralRe: SQL Linq, better idea than a join for as enumerable Pin
jkirkerx12-Nov-15 7:55
professionaljkirkerx12-Nov-15 7:55 
GeneralRe: SQL Linq, better idea than a join for as enumerable Pin
Jörgen Andersson12-Nov-15 9:13
professionalJörgen Andersson12-Nov-15 9:13 
GeneralRe: SQL Linq, better idea than a join for as enumerable Pin
jkirkerx12-Nov-15 10:00
professionaljkirkerx12-Nov-15 10:00 
GeneralRe: SQL Linq, better idea than a join for as enumerable Pin
Jörgen Andersson12-Nov-15 10:06
professionalJörgen Andersson12-Nov-15 10:06 
QuestionFind who dropped a table or column or view Pin
indian1435-Nov-15 7:50
indian1435-Nov-15 7:50 
AnswerRe: Find who dropped a table or column or view Pin
Corporal Agarn5-Nov-15 7:58
professionalCorporal Agarn5-Nov-15 7:58 
AnswerRe: Find who dropped a table or column or view Pin
RNA Team5-Nov-15 18:48
RNA Team5-Nov-15 18:48 
GeneralRe: Find who dropped a table or column or view Pin
Mycroft Holmes5-Nov-15 19:31
professionalMycroft Holmes5-Nov-15 19:31 
AnswerRe: Find who dropped a table or column or view Pin
Afzaal Ahmad Zeeshan8-Nov-15 1:04
professionalAfzaal Ahmad Zeeshan8-Nov-15 1:04 
QuestionWhat is the default isolation level of sqlserver 2008 R2 and 2005 Pin
MyJoiT3-Nov-15 2:15
MyJoiT3-Nov-15 2:15 
AnswerRe: What is the default isolation level of sqlserver 2008 R2 and 2005 Pin
Richard MacCutchan3-Nov-15 2:44
mveRichard MacCutchan3-Nov-15 2:44 
AnswerRe: What is the default isolation level of sqlserver 2008 R2 and 2005 Pin
Afzaal Ahmad Zeeshan3-Nov-15 3:56
professionalAfzaal Ahmad Zeeshan3-Nov-15 3:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.