SQL Update

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

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

  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.
Question by:W.E.B
  • 3
LVL 65

Accepted Solution

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

Updated = Case WHEN POD = '' THEN  Null ELSE 'YES' END,
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..
   JOIN DATABASE1.dbo.ScanItem ScanItem ON DATABASE2.SomeID = ScanItem.SomeID
LVL 11

Expert Comment

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

Author Closing Comment

ID: 38826752
Thank you,
LVL 65

Expert Comment

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

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL server is using more virtual memory. 5 86
Help  needed 3 26
sql 2014,  lock limit 5 32
SSRS 2012 r2 - Parm Drop Down has Date/Time 12 33
Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
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 …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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