I've just tested a TSQL script, locally, that imports data from an XML file into my SQL table. I just had an "oh crap" moment because I'm not sure where to put my XML file so that I can get this data into my SQL Azure DB. I've done some googling but couldn't find how to do this.
Is there a way I can run this SQL against my Azure DB and have it load the contents of my XML file?
Note: Notice this line below:
BULK 'c:\Temp\abook.20130407.1912.xml',
It's on my local PC. I'm not sure where to put this file so I can get this data to Azure.
SET IDENTITY_INSERT Contact ON
INSERT INTO Contact (ContactId, EntityId, Type, Value, Notes)
SELECT X.row.query('field[@name="id"]').value('.', 'INT'),
X.row.query('field[@name="recordid"]').value('.', 'INT'),
X.row.query('field[@name="type"]').value('.', 'VARCHAR(25)'),
X.row.query('field[@name="contact"]').value('.', 'VARCHAR(100)'),
X.row.query('field[@name="notes"]').value('.', 'NVARCHAR(255)')
FROM (
SELECT CAST(x AS XML)
FROM OPENROWSET(
BULK 'c:\Temp\abook.20130407.1912.xml',
SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY x.nodes('/mysqldump/database/table_data[@name="contact"]/row') AS X(row);
SET IDENTITY_INSERT Contact OFF