Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 2nd, 2004, 12:39 PM
mayde78 mayde78 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 83 mayde78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 23 m 54 sec
Reputation Power: 5
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.

Reply With Quote
  #2  
Old August 3rd, 2004, 03:07 PM
briansol briansol is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 briansol User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 )

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Updating Table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT