Loading XML to table producing nothing I'm trying to import part of an xml file into a SQL Server database, but while the query successfully executes there is nothing in the table.

XML:

&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;config&gt;
&lt;company&gt;
&lt;Code&gt;0514&lt;/Code&gt;
&lt;Name&gt;Company A&lt;/Name&gt;
&lt;ContactName&gt;Alan Smith&lt;/ContactName&gt;
&lt;ContactTel&gt;&lt;/ContactTel&gt;
&lt;ContactMail&gt;random@random.net&lt;/ContactMail&gt;
&lt;System&gt;type A&lt;/System&gt;
&lt;/company&gt;
&lt;/config&gt;


Then here is the query I run

DECLARE @XML XML = 'C:\Users\Ramdon\file.xml';
INSERT INTO #tmp_Company2 
SELECT
Code = Events.value('@Code', 'char(6)'),
Name = Events.value('@Name', 'varchar(100)'),
ContactName =Events.value('@ContactName', 'varchar(100)'),
ContactTel =Events.value('@ContactTel', 'varchar(15)'),
ContactMail =Events.value('@ContactMail', 'varchar(100)'),
System =Events.value('@System', 'char(20)'),
FROM @XML.nodes('//config/company') as  XTbl(Events);

select * from #tmp_Company2;


Everything I've read suggests it should work but I get nothing.
As I pointed out your XML file isn't well formed. If you can convert your XML text into this:

declare @XML xml = 
'&lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;config&gt;
   &lt;company&gt;
     &lt;Practice&gt;
       &lt;Code&gt;0514&lt;/Code&gt;
       &lt;Name&gt;Company A&lt;/Name&gt;
       &lt;ContactName&gt;Alan Smith&lt;/ContactName&gt;
       &lt;ContactTel&gt;&lt;/ContactTel&gt;
       &lt;ContactMail&gt;random@random.net&lt;/ContactMail&gt;
       &lt;SystemType&gt;type A&lt;/SystemType&gt;
     &lt;/Practice&gt;
   &lt;/company&gt;
 &lt;/config&gt;';


Then you could use next query to get data content:

select T2.lin.value('(./Code)[1]', 'char(6)') Code,
       T2.lin.value('(./Name)[1]', 'varchar(100)') Name,
       T2.lin.value('(./ContactName)[1]', 'varchar(100)') ContactName,
       T2.lin.value('(./ContactTel)[1]', 'varchar(15)') ContactTel,
       T2.lin.value('(./ContactMail)[1]', 'varchar(100)') ContactMail,
       T2.lin.value('(./SystemType)[1]', 'varchar(100)') System
       into #tmp_Company2
from   @XML.nodes('/config/company/Practice') T2(lin);



select * from #tmp_Company2;
GO



Code   | Name      | ContactName | ContactTel | ContactMail       | System
:----- | :-------- | :---------- | :--------- | :---------------- | :-----
0514   | Company A | Alan Smith  |            | random@random.net | type A



db&lt;>fiddle here