September 24, 2007 at 2:26 am
Hi all,
How can I compare the dates in a column in two separate tables. Actually some of the dates in Table A are missing in Table B. I want to identify those dates.
Thanks
September 24, 2007 at 2:33 am
Hi,
Is there a common column (foreign key) between the tables or is it just a list of dates? If it's just dates you can:
SELECT dateColumn FROM tableA WHERE dateColumn NOT IN (SELECT dateColumn FROM tableB)
September 24, 2007 at 3:34 am
Thanks. Adrian............the script worked fine, but I couldn't solve my problem. I just discovered that all the dates are present in both Tables A and Table B.
Now the issue is to find out which rows of Table A are missing in Table B. How can I check in the absense of any known key. Both Tables A and B are independant tables and I have acquired them from some outer source. Both have different column names but similar data structure. I have no idea about the common key, I though it was date but its not.
Any clues now ?
September 24, 2007 at 4:00 am
Can you provide the DDL (Create statments) for both of the tables? If you could also point out which columns from table A roughly equate to table B, we should be able to help further... 😀
September 24, 2007 at 4:09 am
what is DDL and how can I create statments?. Sorry am a newbie.
September 24, 2007 at 4:35 am
Adrian meant that you should post something like
CREATE TABLE table_a (aid int IDENTITY, some_date DATETIME....)
CREATE TABLE table_b (bid int IDENTITY, aid INT, another_date DATETIME....)
table_b.aid is Foreign key to table_a which will be used to compare dates.
... that's just an example, I have no idea how your data is structured and what you want to compare.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply