Solved

SQL Update

Posted on 2013-01-28
5
267 Views
Last Modified: 2013-01-28
Hello,
can you please help,
the case statement is not working.

if POD column is Empty, then Updated Column is Null else 'YES'

UPDATE DATABASE1.dbo.ScanItem
SET
  POD = DATABASE2.POD,
  PickedUpTime = DATABASE2.PickedUpTime,
  DeliveredTime = DATABASE2.DeliveredTime,
  CCDriverNumber = DATABASE2.PickupDriver,
  Instructions = DATABASE2.Instructions,  
  StatusID = DATABASE2.StatusID,
  ServiceTypeID = DATABASE2.ServiceTypeID,
 Updated = Case when POD = '' THEN  Updated = Null Else 'YES' End,
  OrderDate = DATABASE2.OrderDate
FROM DATABASE2.dbo.ActiveOrders DATABASE2 , DATABASE1.dbo.ScanItem ScanItem
WHERE DATABASE2.OrderNo = ScanItem.CCOrderNo
And DATABASE2.AccountNumber = 3333 and ScanItem.Updated is Null

Any help is appreciated.
0
Comment
Question by:Wass_QA
  • 3
5 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 300 total points
ID: 38826723
Lose the second Updated

Updated = Case WHEN POD = '' THEN  Null ELSE 'YES' END,
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38826734
>FROM DATABASE2.dbo.ActiveOrders DATABASE2 , DATABASE1.dbo.ScanItem ScanItem
btw, I don't see an ON clause that tells SQL how these two tables are joined.
Either this is a cross join, or you need something like..
 
FROM DATABASE2.dbo.ActiveOrders DATABASE2
   JOIN DATABASE1.dbo.ScanItem ScanItem ON DATABASE2.SomeID = ScanItem.SomeID
0
 
LVL 11

Expert Comment

by:David Kroll
ID: 38826742
Updated = Case when POD = '' THEN  Null Else 'YES' End,
0
 

Author Closing Comment

by:Wass_QA
ID: 38826752
Thank you,
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38826760
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now