Solved

SQL Update

Posted on 2013-01-28
5
296 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 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:W.E.B
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

697 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