Practice Activity - remove duplicate rows in SQL Server (three different ways)

Veröffentlicht am: 07 April 2022
auf dem Kanal: SQL Server 101
12,385
139

Duplicate rows are very annoying. But how can you remove them in SQL Server?
My SQL Server Udemy courses are:
70-461, 70-761 Querying Microsoft SQL Server with T-SQL: https://rebrand.ly/querying-microsoft...
98-364: Database Fundamentals (Microsoft SQL Server): https://rebrand.ly/database-fundamentals
70-462 SQL Server Database Administration (DBA): https://rebrand.ly/sql-server-dba
Microsoft SQL Server Reporting Services (SSRS): https://rebrand.ly/sql-server-ssrs
SQL Server Integration Services (SSIS): https://rebrand.ly/sql-server-ssis
SQL Server Analysis Services (SSAS): https://rebrand.ly/sql-server-ssas-mdx
Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): https://rebrand.ly/microsoft-powerpiv...
----
Duplicate rows may lead to erroneous conclusions, so often you will want them to be deleted. But how can you identify them?
In this video, we'll have a look at three different ways at how we can get rid of them, using DISTINCT, GROUP BY, and UNION - but which is better?

The starting code is:
DROP VIEW IF EXISTS WithDuplicates
GO
CREATE VIEW WithDuplicates AS
SELECT *
FROM sys.objects
UNION ALL
SELECT *
FROM sys.objects
SELECT object_id, [name]
FROM WithDuplicates
ORDER BY object_id

The code that I used in this video is:
SELECT DISTINCT object_id, [name]
FROM WithDuplicates
ORDER BY object_id

SELECT object_id, [name]
FROM WithDuplicates
GROUP BY object_id, [name]
ORDER BY object_id

SELECT object_id, [name]
FROM WithDuplicates
UNION
SELECT object_id, [name]
FROM WithDuplicates
ORDER BY object_id


Auf dieser Seite können Sie das Online-Video Practice Activity - remove duplicate rows in SQL Server (three different ways) mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer SQL Server 101 07 April 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 12,385 Mal angesehen und es wurde von 139 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!