One possibility for those is a bit shorter...
NULLIF(A.CALC_Date_EOIReceived,'1900-01-01 00:00:00.000') AS [Date Req Created]
NULLIF(A.CALC_Date_EOIReceived,'1900-01-01 00:00:00.000') AS [Date Initiated]
If we could see the rest of the code, we could probably "DRY" that out a whole lot more with either a CTE or a CROSS APPLY although the CROSS APPLY can sometimes make things a bit slower.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 14, 2022 at 9:07 am
@jeff Moden
Thanks a lot, I have almost finished and submitted. Firstly thank you for the NULLIF.. that is my learning.
2. Once I am done with this, I will create a separate thread with this link and seek help on other smart ways..
Thanks a ton and
Happy Easter / Holidays
April 14, 2022 at 2:55 pm
Yes, there is a better way. You can use CROSS APPLY(s) to assign alias name(s).
SELECT [Date Req Created], [Date Initiated], ...
FROM ...
CROSS APPLY (
SELECT NULLIF(A.CALC_Date_EOIReceived, '19000101') AS [Date Req Created]
) AS ca1
CROSS APPLY (
SELECT [Date Req Created] AS [Date Initiated]
) AS ca2
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
Viewing 3 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply