Tags Posts tagged with "table"

table

4

Hmm… I have been using SQL for quite some time. But I do not know how to compare 2 tables to find out the different records. For example, I have 2 tables which are table A and table B. Both of them have some similar records. But I want to filter out the different data only. How can I do so? I searched online and discovered the method to do so. It is located in Microsoft SQL Server 2005 Books Online. All we need to do is use EXCEPT function in SQL.

Query to compare 2 tables to find the different

SELECT * FROM TableA EXCEPT SELECT * FROM TableB;

Query to compare 2 tables to find the matches

SELECT * FROM TableA INTERSECT SELECT * FROM TableB;

Hope this will help you too. ;)

0

How to delete / drop SQL table? The following code will guide you to drop the temporary SQL table. Basically, you just need to type in ‘DROP TABLE tableName‘.

IF OBJECT_ID(N’tempdb..#temptable’, N’U’) IS NOT NULL
DROP TABLE #temptable;
GO

SOCIAL

2,294FansLike
319Subscribers+1
267FollowersFollow
3,546SubscribersSubscribe