RD11
asked on
SQL Join Query question
Hi,
I have the below query that works on one column, then creates a table from the result that gets.
I need a query that checks 3 columns then creates the table from the result.
I need to check for any change for the columns [ps].ASE, [ps].Env, [ps].City
Thank you,
RD11
I have the below query that works on one column, then creates a table from the result that gets.
I need a query that checks 3 columns then creates the table from the result.
I need to check for any change for the columns [ps].ASE, [ps].Env, [ps].City
Thank you,
RD11
SELECT [ps].ETag, [ps].Host, [ps].[Private Input], [ps].[From ci db], [ps].[ID-PK], [ps].Src, [ps].ASE, [ps].Env, [ps].EnvD, [ps].Cls [ps].City, [ps].[Surpluss EST], [ps].[Monthly Cost], [ps].Description, [ps].[Install Date], [ps].[Purchase Date], [ps].Env, [ps].Pool, [ps].Billed, [ps].Price, [ps].[C Org], [ps].[Resp], [ps].Function,[ps].Comments, [ps].[Last Update], [ps].OS, [ps].Status INTO Diff_table
FROM [ps] LEFT JOIN cI_table ON [ps].Host = cI_table.HOST
WHERE (((cI_table.HOST) Is Null));
ASKER
If any change in either any one of them.
This line will get the rows that are not in the diff table based on the three columns
where not exists (select 1 from Diff_table B where [ps].ASE = B.ASE and [ps].Env = B.Env and [ps].City = B.City)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I actually DO NOT have a primary Key, I am using the Host name as a PK. Can I still do that?
That should work
ASKER
Thank you
Checks the three columns exactly for what?
If they are different in the diff table, you can use exists
Open in new window