[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL Update

Posted on 2013-01-28
5
Medium Priority
?
317 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:W.E.B
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 66

Accepted Solution

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

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

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:W.E.B
ID: 38826752
Thank you,
0
 
LVL 66

Expert Comment

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

656 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