I have the above table and I want to create a DATETIME value from it.
I've tried a number of ways using CONCAT, CONVERT and CAST to glue these together in a way that produces a datetime value and can't get there. I can produce a string that will convert like this.
CONCAT(
'''',
Year,
'-',
CASE LEN(Month) WHEN 1 THEN CONCAT('0', LTRIM(RTRIM(STR(Month)))) ELSE CAST(Month AS VARCHAR(2)) END,
'-',
CASE LEN(Day) WHEN 1 THEN CONCAT('0', LTRIM(RTRIM(STR(Day)))) ELSE CAST(Day AS VARCHAR(2)) END,
' ',
Hour,
':00:00.000',
''''
)
However, I wrap that output in a call to cast or convert it fails.
Can someone point me in the right direction?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…