Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- merge Production.Suppliers as target
- using (
- select
- MY_XML.Company.query('companyname').value('.', 'nvarchar(40)') as companyname,
- MY_XML.Company.query('contacttitle').value('.', 'nvarchar(40)') as contacttitle,
- MY_XML.Company.query('contactname').value('.', 'nvarchar(40)') as contactname,
- MY_XML.Company.query('postalcode').value('.', 'nvarchar(40)') as postalcode
- from (select cast(MY_XML as xml)
- from openrowset(bulk 'C:\Users\----\Suppliers.xml', single_blob) --tu sciezka nowa!!!!
- as T(MY_XML)) AS T(MY_XML)
- cross apply MY_XML.nodes('Suppliers/Company') as MY_XML (Company)
- ) as source
- on target.companyname = source.companyname
- when matched then update set contacttitle = source.contacttitle, contactname = source.contactname, postalcode = source.postalcode
- when not matched then insert(companyname, contacttitle, contactname, postalcode) values(source.companyname, source.contacttitle, source.contactname, source.postalcode);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement