Where is the varchar statement .... in the following SQL Code

Hi Experts

Where is the varchar statement in the following code.....



SELECT 

snapshot_date,
contact_part_id,
contact_id,
case_status,
primary_flag,
void_flag,
demand_type,
created_datetime,
CAST([created_dateonly] AS DATETIME) AS [created_dateonly],
part_type,
product_01,
product_02,
product_03,
product_04,
cal_days_part_to_cr,
cal_days_part_to_log,
bus_days_part_to_cr,
bus_days_part_to_log,
hour_part_created,
multi_issues_percentage,
part_redress_honouring_product,
part_redress_writeoff,
part_redress_01_distress_and_inconvenience,
part_redress_03_customer_expenses,
part_redress_09_operational_loss,
cal_days_parts_outstanding_dib,
bus_days_parts_outstanding_dib,
cal_days_parts_outstanding_dicr,
bus_days_parts_outstanding_dicr,
cal_days_parts_outstanding_created,
bus_days_parts_outstanding_created,
cal_days_parts_e2e,
bus_days_parts_e2e,
acc_email,
ad,
add_if_differs,
advisor_name_initials,
advisor_name_surname,
advisor_name_title,
advisor_staff_id,
advisor_uk,
asap,
attitude_to_risk,
cause_where_01,
cause_where_02,
cause_where_03,
cause_where_04,
clc,
colleague,
complaint_area_1_01,
complaint_area_1_02,
complaint_area_2_01,
complaint_area_2_02,
complaint_area_3_01,
complaint_area_3_02,
complaint_details,
complexity,
consultant,
contact_method,
crf_amended,
CAST([date_outcome_dateonly] AS DATETIME) AS [date_outcome_dateonly],
pull_01_datetime,
pull_03_datetime,
date3_datetime,
date_closed_cpov_datetime,
date_closed_fsa_cp_datetime,
date_comp_pull_01_datetime,
date_comp_pull_02_datetime,
date_comp_pull_03_datetime,
date_comp_pull_04_datetime,
CAST([date_defect_dis_dateonly] AS DATETIME) AS [date_defect_dis_dateonly],
date_flagged_rl_datetime,
date_moved_in_datetime,
CAST([date_of_sale_dateonly] AS DATETIME) AS [date_of_sale_dateonly],
CAST([date_of_survey_datetonly] AS DATETIME) AS [date_of_survey_datetonly],
date_req_datetime,
date_stage1_datetime,
dfii,
dfir,
dfiu,
dpm,
dt_in_crcp_datetime,
ees_client,
eligibility,
error_no,
explanation,
face2face,
feedback_provided,
CAST([final_dateonly] AS DATETIME) AS [final_dateonly],
final_dl,
fpoc

FROM  tbl_TB

Open in new window

route217JuniorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
VARCHAR is a type definition for a column.  You would not find it in a select statement.  Why are you asking?
0
route217JuniorAuthor Commented:
keep on getting an error....saying:

the conversion of a varchar data type to a a datetime date type resulted in an out-of-range value.
0
PortletPaulfreelancerCommented:
in one of these the field referenced by the CAST function is unable to perform that operation as the field's data type is varchar and somewhere in that data is a value that does not allow conversion to datetime.
CAST([date_outcome_dateonly] AS DATETIME) AS [date_outcome_dateonly],
...
CAST([date_defect_dis_dateonly] AS DATETIME) AS [date_defect_dis_dateonly],
...
CAST([date_of_sale_dateonly] AS DATETIME) AS [date_of_sale_dateonly],
CAST([date_of_survey_datetonly] AS DATETIME) AS [date_of_survey_datetonly],

Open in new window

0
PortletPaulfreelancerCommented:
try each independently as a way of identifying which fields are the problem(s) e.g.
select count(*) from (
select
CAST([date_outcome_dateonly] AS DATETIME) AS [date_outcome_dateonly]
FROM  tbl_TB
) as test

Open in new window

repeat for each cast line in previous comment (don't forget to remove the trailing comma)

{+ edit} think I missed this one:
CAST([final_dateonly] AS DATETIME) AS [final_dateonly],
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PortletPaulfreelancerCommented:
Thanks & Cheers, Paul

btw: I will make a tiny change to heading: "i sthe" to "is the".
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.