|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Updating Table
I have following data table.
disp_id disp_date disp_tgasals disp_ccsales disp_locid 8 7/20/2004 <NULL> 114876 1 9 7/20/2004 <NULL> 25980 2 10 7/20/2004 <NULL> 43012 3 11 7/20/2004 <NULL> 38574 4 If i run the following sql statement INSERT DisplayTran (disp_tgasals) SELECT SUM(DailyTran.dlt_amt) FROM DailyTran INNER JOIN .GLedger ON DailyTran.dlt_glfk = GLedger.gld_pk INNER JOIN Locations ON DailyTran.dlt_locfk = Locations.loc_pk AND GLedger.gld_locfk = Locations.loc_pk WHERE (GLedger.gld_glno = '33101' OR GLedger.gld_glno = '33111' OR GLedger.gld_glno = '33121') AND (DailyTran.dlt_date = @dlt_date) AND (DailyTran.dlt_locfk = @dlt_locfk) GO Now the select statement will display data something like 5678 7890 8990 8909 and add it to the data table as disp_id 12, 13, 14, 15. Instead i want it to update the data table for ids 8, 9, 10, 11 for the disp_tgassals columns. |
|
#2
|
|||
|
|||
|
the biggest thing: change "INSERT" to "UPDATE"
and you need to specify WHAT to update update TABLE SET (8,9,10) VALUES (Select... to get 8,9,10 results you want) WHERE some condition (not necessarily needed ) |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Updating Table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|