1
I need to load a table into a database with data from another table and another database. It turns out that in the Datetime field is giving a conversion error, because the data of the other table is in Varchar. See how I did:
use [Rup]
insert into [dbo].[Ruptura]
(
DataRuptura ===>>> AQUI DÁ O ERRO
,[IDJustificativa]
,[IDOrigem]
,[CodigoPDV]
,[Codigo_Apresentacao]
)
select
Convert(DateTime,stg.DATA,103)==>> Tentativa e não deu certo
,mot.MOTNM_CODIGO AS RUPTURA
,1 AS ORIGEM
,pdv.PDVCH_CODIGO AS CODIGO_PDV
,apr.APRCH_COD_ACHE AS CODIGO_EAN
from [STG_Rup].[dbo].[RPT_STG_CARGA] stg
join [STG_Rup].[dbo].[RPT_CAT_MOTIVO_RUPTURA] mot on stg.JUSTIFICATIVA = mot.MOTCH_MOTIVO_RUPTURA
join [STG_Rup].[dbo].[MDTR_CAT_PDV] pdv on stg.CNPJ = pdv.PDVCH_CNPJ
join [STG_Rup].[dbo].[VDA_CAT_APRESENTACAO] apr on stg.EAN = apr.APRCH_COD_EAN
The stg.Data field is a varchar(100)