I'm trying to insert data into a table using a select statement as my source,within this select statement I'm retrieving a field that contains a date that is stored as an integer value within,but SQL doesn't like it.
Statement:
EXEC
('INSERT INTO dbo.STG_AML_Customers_list
SELECT
CO_CDE AS CompanyCode,
CUST_FULL_NAME_1 AS CustomerName,
CUST_REC_OPEN_DATE AS CustomerOpenDate,
CUST_TYPE AS CustomerType,
CUST_NO CustomerNumber,
KYC_IND AS KYCIndicator
FROM andwhs01.cpc.dbo.DIM_CUSTOMER_MONTHLY_'+ @Reporting_Month + '
WHERE co_cde = 15
')
Below is the error message it provides:
Server: Msg 260, Level 16, State 1, Procedure SP_aml_Customer_List, Line 26
Disallowed implicit conversion from data type datetime to data type int, table 'CPC.dbo.AML_Customers_list', column 'CustomerOpenDate'. Use the CONVERT function to run this query.
Statement:
EXEC
('INSERT INTO dbo.STG_AML_Customers_list
SELECT
CO_CDE AS CompanyCode,
CUST_FULL_NAME_1 AS CustomerName,
CUST_REC_OPEN_DATE AS CustomerOpenDate,
CUST_TYPE AS CustomerType,
CUST_NO CustomerNumber,
KYC_IND AS KYCIndicator
FROM andwhs01.cpc.dbo.DIM_CUSTOMER_MONTHLY_'+ @Reporting_Month + '
WHERE co_cde = 15
')
Below is the error message it provides:
Server: Msg 260, Level 16, State 1, Procedure SP_aml_Customer_List, Line 26
Disallowed implicit conversion from data type datetime to data type int, table 'CPC.dbo.AML_Customers_list', column 'CustomerOpenDate'. Use the CONVERT function to run this query.