There is one column: OpenedDate with datatype: varchar(8) and I want to convert it into datetime but since OpenedDate has erroneous values of 0's. First- I want to convert the 0's into NULLs using the query: CASE WHEN Opened_dt = '0' then 'NULL' else Opened_dt end as 'Opened_dt_converted' Now, I want to use the above results to convert the datatype to DateTime using the syntax: CONVERT(DATETIME, 'Opened_dt_converted',120)
I was thinking if I should use Nested query or create a stored procedure but I am not sure how can I use the nested query for this type of situation? Basically, I want this whole query in one stored procedure. Could you please help me in achieving that task?
Thanks in advance! Geetanjali