IF you have tables A
and B
, both with colum C
, here are the records, which are present in table A
but not in B
:
SELECT A.* FROM A LEFT JOIN B ON (A.C = B.C) WHERE B.C IS NULL
To get all the differences with a single query, a full join must be used, like this:
SELECT A.*, B.* FROM A FULL JOIN B ON (A.C = B.C) WHERE A.C IS NULL OR B.C IS NULL
What you need to know in this case is, that when a record can be found in A
, but not in B
, than the columns which come from B
will be NULL, and similarly for those, which are present in B
and not in A
, the columns from A
will be null.
Related Posts:
- T-SQL split string
- Conversion of a varchar data type to a datetime data type resulted in an out-of-range value in SQL query
- How to find sum of multiple columns in a table in SQL Server 2005?
- How can I delete using INNER JOIN with SQL Server?
- Conversion of a varchar data type to a datetime data type resulted in an out-of-range value in SQL query
- How can I get column names from a table in SQL Server?
- What is the maximum characters for the NVARCHAR(MAX)?
- How to format a numeric column as phone number in SQL
- How to select the last record of a table in SQL?
- Selecting COUNT(*) with DISTINCT
- Inserting multiple rows in a single SQL query? [duplicate]
- SQL query to select dates between two dates
- SQL query to get the employee name and their manager name from the same table
- How can I do an UPDATE statement with JOIN in SQL Server?
- Rename column SQL Server 2008
- INSERT statement conflicted with the FOREIGN KEY constraint – SQL Server
- Efficiently convert rows to columns in sql server
- How to delete duplicate rows in SQL Server?
- The SQL OVER() clause – when and why is it useful?
- Update multiple columns in SQL
- INSERT statement conflicted with the FOREIGN KEY constraint – SQL Server
- SQL Query with NOT LIKE IN
- SQL Server IF EXISTS THEN 1 ELSE 2
- T-SQL split string based on delimiter
- SQL Query with SUM with Group By
- How do I perform an IF…THEN in an SQL SELECT?
- SQL update from one Table to another based on a ID match
- An attempt was made to access a socket in a way forbidden by its access permissions
- How to drop all tables from a database with one SQL query?
- SQL Server : Arithmetic overflow error converting expression to data type int
- How to calculate percentage with a SQL statement
- Column name or number of supplied values does not match table definition
- Query comparing dates in SQL
- Best way to do nested case statement logic in SQL Server
- What is the meaning of the prefix N in T-SQL statements and when should I use it?
- The multi-part identifier could not be bound
- Query error with ambiguous column name in SQL
- How to drop all tables from a database with one SQL query?
- SQL Server Insert if not exists
- CREATE TABLE IF NOT EXISTS equivalent in SQL Server
- SQL Server: Invalid Column Name
- How to group by month from Date field using sql
- Is there a combination of “LIKE” and “IN” in SQL?
- Search text in stored procedure in SQL Server
- Add a column with a default value to an existing table in SQL Server
- MS SQL compare dates?
- MS SQL compare dates?
- What represents a double in sql server?
- How do I fix ‘Invalid character value for cast specification’ on a date column in flat file?
- Determine ROW that caused “unexpected end of file” error in BULK INSERT?
- Determine ROW that caused “unexpected end of file” error in BULK INSERT?
- Using RegEx in SQL Server
- Microsoft OLE DB Provider for SQL Server error ‘80004005’
- Bulk load data conversion error (truncation)
- Difference between database and schema
- SQL – WHERE (X, Y) IN (A, B)
- How do I fix the error ‘Named Pipes Provider, error 40 – Could not open a connection to’ SQL Server’?
- SQL: IF clause within WHERE clause
- Backup a single table with its data from a database in sql server 2008
- how to increment integer Columns value by 1 in SQL
- How can I group by date time column without taking time into consideration
- SQL- Ignore case while searching for a string
- Comma separated results in SQL
- SHOWPLAN permission denied in database ‘tempdb’. in sql server 2008
- “select * into table” Will it work for inserting data into existing table
- Filter data based on date in sql
- CASE IN statement with multiple values
- Varchar invalid for Sum operator
- Using Excel VBA to run SQL query
- What is tableName.* in SQL
- What do Clustered and Non-Clustered index actually mean?
- Conversion failed when converting date and/or time from character string while inserting datetime
- Must declare the scalar variable
- How do I escape a single quote in SQL Server?
- Data source name not found, and no default driver specified
- Optimistic vs. Pessimistic locking
- Can a foreign key be NULL and/or duplicate?
- How do I do multiple CASE WHEN conditions using SQL Server 2008?
- When to use SELECT … FOR UPDATE?
- Difference between JOIN and INNER JOIN
- The target principal name is incorrect. Cannot generate SSPI context
- Check if table exists in SQL Server
- SQL Server WITH statement
- SQL Server reports ‘Invalid column name’, but the column is present and the query works through management studio
- What is the equivalent of ‘describe table’ in SQL Server?
- Remote table-Valued Function Calls are not allowed
- The backend version is not supported to design database diagrams or tables
- Get size of all tables in database
- Exclude a column using SELECT * [except columnA] FROM tableA?
- What is the difference between a stored procedure and a view?
- Why is SQL server throwing this error: Cannot insert the value NULL into column ‘id’?
- How do I fix the multiple-step OLE DB operation errors in SSIS?
- SQL Server: Error converting data type nvarchar to numeric
- How do I format a number with commas in T-SQL?
- Can I use multiple “with”?
- Incorrect syntax near ”
- To add server using sp_addlinkedserver
- How to connect to a local database in SQL Server Management Studio?
- Arithmetic overflow error converting varchar to data type numeric. ’10’ <= 9.00
- What are named pipes?