Insert INTO Kraft_sync_store (storename,storecode,province,prefecturecity,countycity,region,area,unit,hqka,kaname , Storetype,isvalid,contactperson,mobiletelephone,telephone,address,latitude,longitude,regiongroup, Sfastoremanagername) Select CAST (storename as nvarchar), storecode,province,prefecturecity,countycity,region, Area,unit,hqka,kaname,storetype,isvalid,contactperson,mobiletelephone,telephone,address,latitude,longitude, Regiongroup,sfastoremanagername from OpenDataSource ( ' SQLOLEDB ', ' Data source=10.100.6.114; User Id=ismea; Password=ie1q2w3e4r ' ). WARIS.dbo.I_V_Store
For reading between multilingual versions of databases, it is possible to have garbled Chinese characters. So the above code OPENDATASOURCE read the remote database garbled situation. Should be replaced by the following Linkserver way:
CREATE PROCEDURE [dbo]. [Sp_getsyncstore_insert] @storecode nvarchar (+) Asif NOT exists (select name from sys.servers where name = ' SSO ') begin EXE C sp_addlinkedserver ' SSO ', ' ', ' SQLOLEDB ', ' 10.100.6.114 ' exec sp_addlinkedsrvlogin ' SSO ', ' false ', NULL, ' Ismea ', ' ie1q2w3e4r ' Enddelete kraft_sync_store where [Email protected]exec (' INSERT into Kraft_sync_store (StoreName, Storecode,province,prefecturecity,countycity,region,area,unit,hqka,kaname,storetype,isvalid,contactperson, Mobiletelephone,telephone,address,latitude,longitude,regiongroup,sfastoremanagername,storetypegroup, Regiongroupch,createtime) Select Storename,storecode,province,prefecturecity,countycity,region,area,unit,hqka, Kaname,storetype,isvalid,contactperson,mobiletelephone,telephone,address,latitude,longitude,regiongroup, Sfastoremanagername,storetypegroup, "', GETDATE () Createtime from SSO. WARIS.dbo.I_V_Store where storecode= ' [email protected]+ ']; update a set A.REGIONGROUPCH=B.REGIONCODECN from Kraft_sync_stOre aleft join Kraft_regioncodes b on A.regiongroup=b.regioncodeenwhere [email protected]exec sp_dropserver ' SSO ', ' Droplogins ' GO
OPENDATASOURCE reading remote database Data Chinese garbled problem-sqlserver R2