Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Babli
Yak Posting Veteran
53 Posts |
Posted - 2007-05-23 : 23:23:23
|
| Hi,I have a table "originaldata" with the below columnsContext,Action/Recommendation ,WhyAnother table called "tblcontextaction" with the below columnsContext,ActionRecommendation ,WhyNow I need to update the Why of "currentdata" with the Why of"originaldata".The Context and ActionRecommendation of each of the two tables are the same.I tried the below query to check if I am getting the correct records for updating.Select t1.Context,t1.ActionRecommendation from tblcontextaction t1inner join originaldata t2on t2.Context = t1.COntextand t2.[Action/Recommendation] = t1.[ActionRecommendation]I am not getting the desired results the resultset is going on and on.Please help. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-23 : 23:29:58
|
quote: Now I need to update the Why of "currentdata" with the Why of"originaldata".
currentdata or tblcontextaction ?quote: I am not getting the desired results the resultset is going on and on.
What do you mean going on and on ? KH |
 |
|
|
Babli
Yak Posting Veteran
53 Posts |
Posted - 2007-05-23 : 23:35:26
|
| The select query is not working.Select t1.Context,t1.ActionRecommendation from tblcontextaction t1inner join originaldata t2on t2.Context = t1.COntextand t2.[Action/Recommendation] = t1.[ActionRecommendation]This query is going on and on |
 |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2007-05-23 : 23:35:33
|
| When you say the resultset is going on and on what exactly do you mean?a) The query takes a long time to run?Try filtering (where context = ????) and seeing if the matching records are correct this should return faster if you filtered to a small set of records.b) Too many matching recordsVerify that you are joining on the correct unique set of values or key.AlsoAre Context and [action/recommendation] a unique combination for each table or do they repeat?How many records in each of your two tables?select count(*) from originaldataselect count(*) from tblcontextactionHow many distinct context, [action/recommendation]?select context, [action/recommendation],count(*) from originaldatagroup by context, [action/recommendation]select context, [actionrecommendation],count(*) from tblcontextactiongroup by context, [actionrecommendation]What does this return?select count(*) from tblcontextaction t1 inner join originaldata t2on t1.context = t2.context and t1.actionrecommendation = t2.[action/recommendation] |
 |
|
|
|
|
|
|
|