โค้ดผม จะ insert ข้อมูลจาก sql ไปที่ link server ของ mysql แปลงtype ให้ตรงกันแล้ว ก็ไม่ได้สามารถinsert ได้ครับ
INSERT INTO OPENQUERY(ANGELMYSQL
,'SELECT CompID
,CompanyCode
,CompanyDesc
,CompanyGroup
,CompanyAlis
,CustomerCode
,Active
,TaxID
,CurrencyNo
,FormatDate
,UpdateBy
,UpdateDateTime
,CreateBy
,CreateDateTime FROM angelsystem.tbm_company')
SELECT
CAST(CompID as varchar(5))
,CAST(CompanyCode as varchar(4))
,CAST(CompanyDesc as varchar(max)) ในmysql เป็น longtext
,CAST(CompanyGroup as varchar(10))
,CAST(CompanyAlis as varchar(10))
,CAST(CustomerCode as varchar(4))
,CAST(Active as int)
,CAST(TaxID as int)
,CAST(CurrencyNo as varchar(4))
,CAST(FormatDate as varchar(20))
,CAST(UpdateBy as varchar(20))
,CAST(UpdateDateTime as datetime2(6))
,CAST(CreateBy as varchar(20))
,CAST(CreateDateTime as datetime2(6)) From [TestAutoUpdateESTORE].[dbo].TBM_CompanyTEST
ส่วนของ error
Msg 7399, Level 16, State 1, Procedure dbo.EDITEOROR, Line 18 [Batch Start Line 2]
The OLE DB provider "MSDASQL" for linked server "ANGELMYSQL" reported an error. The provider did not give any information about the error.
Msg 7343, Level 16, State 2, Procedure dbo.EDITEOROR, Line 18 [Batch Start Line 2]
The OLE DB provider "MSDASQL" for linked server "ANGELMYSQL" could not INSERT INTO table "[MSDASQL]". Unknown provider error.