View Complete Post
is there an easy way to compare two columns in two datatable to see if they match?
I need to check if the values in column["x"] of datatable1 occur in column ["y"] of datatable2, without iterating through both tables (for each value in column of dt1, check column of dt2).
foreach (DataRow dr in dt1.rows)
but this checks the whole row and if finds an "x" in any column, "if" condition is true. I need to only check one column of dt2.
Tables have different columns but the same primary column and that's what I need to check
Dealing with error handling between T-SQL and a calling application, evaluating when a field's value has changed, and creating auditing tables in SQL ServerT are all common issues that developers must tackle.
MSDN Magazine April 2004
I am well versed with Join/Outer Join/Inner Join. My question is not related to normal Joining of two tables. Its little complex. Let me see if I can explain well.
There are two tables, were data is stored.
Name_Info : nvarchar(10)
Date_Info : smalldate()
Spec_Info_1 : tinyint
Spec_Info_2 : tinyint
Spec_Info_3 ; tinyint
Name_Data : nvarchar(10)
City_Data : nvarchar(10)
State_Data : nvarchar(10)
To join these two tables, I use the following query (joined on Name_Info ON Name_Data)
SELECT Name, Date=CONVERT(varchar, Date, 101), City, State,
CASE Spec_Info_1 WHEN '0' THEN 'House' WHEN '2' THEN 'Shop' WHEN '3' THEN 'Bay' ELSE '-'
END AS Spec_Info_1,
CASE Spec_Info_2 WHEN '0' THEN '10 Feet' WHEN '2' THEN '20 Feet' WHEN '3' THEN '40 Feet' ELSE '-' END AS Spec_Info_2,
CASE Spec_Info_3 WHEN '0' THEN '2 Windows' WHEN '2' THEN '4 Windows' WHEN '3' THEN '6 Windows' ELSE '-'
END AS Spec_Info_3
FROM Table_Spec_Data LEFT OUTER JOIN Table_Name_Data On Table_Spec_Data.Name_Info=Table_Name_Data.Name_Data
I need to insert/update data to 3 or more tables on a single button click.What is best method for achieving this?I am using mysql as my DB.
Thanks for your valuable reply in advance.
I need to compare the current price to an old price and not quite sure how to approach it. I am bringing in 3 CTE's that contain all of the data. Then # the bottom I'v got effective dates but I'm not sure how to re-write this and compare current prices to the old price that was effective before. The DNC Column is the column i have to compare in the last query
declare @dt datetime
set @dt = getdate();
With itmlvl as (
How to find who deleted records from table