MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

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 Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old September 20th, 2004, 08:28 AM
acorncomputers acorncomputers is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 8 acorncomputers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Update table

I have two tables: product_table and synnex. I want to update the weight field in product_table with the shipping_weight field in synnex. I only want to update the fields where product_table.sku = synnex.sku. How do I do this? Thanks in advance for your help

Reply With Quote
  #2  
Old September 20th, 2004, 08:32 AM
WurzelGummidge WurzelGummidge is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 5 WurzelGummidge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
try this:

update product_table set weight = syn.shipping_weight
from synnex syn where syn.sku = product_table.sku

Reply With Quote
  #3  
Old September 20th, 2004, 08:47 AM
acorncomputers acorncomputers is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 8 acorncomputers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Didn't work

I tried this and I get an error message that says I have a missing operator

Quote:
Originally Posted by WurzelGummidge
try this:

update product_table set weight = syn.shipping_weight
from synnex syn where syn.sku = product_table.sku

Reply With Quote
  #4  
Old September 20th, 2004, 09:10 AM
WurzelGummidge WurzelGummidge is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 5 WurzelGummidge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
mmm.. just checked and double checked my syntax and should work perfectly n- please check your syntax again?

Reply With Quote
  #5  
Old September 20th, 2004, 09:51 AM
acorncomputers acorncomputers is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 8 acorncomputers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
BTW--thanks for your help on this.

I didn't want to mess with my "real" tables so I created two new ones for testing: table_one and table_two

Here is the code I inputted and get the syntax error with:

update table_one set weight = syn.shipping_weight
from table_two syn where syn.sku = table_one.sku

Please advise...thanks!

Quote:
Originally Posted by WurzelGummidge
mmm.. just checked and double checked my syntax and should work perfectly n- please check your syntax again?

Reply With Quote
  #6  
Old September 20th, 2004, 10:04 AM
WurzelGummidge WurzelGummidge is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 5 WurzelGummidge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
If your table names are 'table_one' and 'table_two', this 'should' do it:

update table_one set weight = t2.shipping_weight
from table_two t2 where table_one.sku = t2.sku

Reply With Quote
  #7  
Old September 20th, 2004, 10:31 AM
acorncomputers acorncomputers is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 8 acorncomputers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I finally got it to work with this:

update table_one, table_two
set weight = table_two.shipping_weight
WHERE table_two.sku=table_one.sku

Thanks for your help

Quote:
Originally Posted by WurzelGummidge
If your table names are 'table_one' and 'table_two', this 'should' do it:

update table_one set weight = t2.shipping_weight
from table_two t2 where table_one.sku = t2.sku

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Update 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 2 hosted by Hostway