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 |
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2010-08-20 : 02:51:39
|
| Friends,I am having one table name "Requested" i want to update this table using temporary table value, please find my table structure and temp table values for your reference.Table : Requested---------------------RequestCode|SNO|RefCode|FuncCode|ROWCode|UpdateCode|StatusCode10901 | 1 | 70 | 1000 | 102 | 10002334 | 110901 | 2 | 70 | 1000 | 108 | 11900202 | 110901 | 3 | 71 | 1001 | 108 | 12322455 | 1 10901 | 4 | 70 | 1000 | 119 | 12002012 | 110902 | 1 | 70 | 1000 | 122 | 31212121 | 110902 | 1 | 71 | 1004 | 133 | 23232323 | 1TempTable : #TempCompareTbl----------------------------TRequestCode|TRefCode|TFuncCode|TROWCode|TUpdateCode|TStatusCode10901 | 70 | 1000 | 102 | 45444455 | 310901 | 70 | 1000 | 119 | 65566565 | 2I have to compare "#TempCompareTbl" Column TRequestCode|TRefCode|TFuncCode|TROWCode in WHERE Condition with "Requested" Table Column RequestCode|RefCode|FuncCode|ROWCode|And update What value we have in "#TempCompareTbl" Column TUpdateCode|TStatusCode TO "Requested" table Column UpdateCode|StatusCode.Expected Output After Executing the Query isEXPECTED OUTPUT----------------Table : Requested---------------------RequestCode|SNO|RefCode|FuncCode|ROWCode|UpdateCode|StatusCode10901 | 1 | 70 | 1000 | 102 | 45444455 | 310901 | 2 | 70 | 1000 | 108 | 11900202 | 110901 | 3 | 71 | 1001 | 108 | 12322455 | 1 10901 | 4 | 70 | 1000 | 119 | 65566565 | 210902 | 1 | 70 | 1000 | 122 | 31212121 | 110902 | 1 | 71 | 1004 | 133 | 23232323 | 1Please help me to get the expected output. |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-08-20 : 02:58:43
|
| UPDATE Requested SET UpdateCode = T.TUpdateCode, StatusCode = T.TStatusCodeFROM #TempCompareTbl TINNER JOIN Requested R ON T.TRequestCode = R.RequestCode AND T.TRefCode = R.RefCode AND T.TFuncCode = R.FuncCode AND T.TROWCode = R.ROWCodeVaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2010-08-20 : 03:03:15
|
| Hi Vaibhav,Thanks for your Rapid response,Let me try this and let you know.Thanks Again |
 |
|
|
|
|
|