sql >> Database teknologi >  >> Database Tools >> SSMS

Får XML til at føres ind i SQL Server-tabel

Her er justeret fungerende SQL. Du skal bare fjerne kommentarene fra INDSÆT linjerne, når du er klar.

SQL

WITH XmlFile (xmlData) AS
(
   SELECT CAST(BulkColumn AS XML) 
   FROM OPENROWSET(BULK 'C:\Users\cj\Documents\EodBalance.xml', SINGLE_BLOB) AS x
)
--INSERT INTO [dbo].[EndofDay] 
--([PouchID], [Lane], [BusinessDay], BusinessStartingTime, BusinessEndingTime, [StartingBalance], [EndingBalance])
SELECT c.value('(PouchId/text())[1]', 'VARCHAR(25)') AS [PouchId]
   , c.value('(Lane/text())[1]', 'NCHAR(2)') AS [Lane]
   , c.value('(BusinessDay/text())[1]', 'DATE') AS [BusinessDay]
   , c.value('(BusinessStartingTime)[1]', 'datetime') AS [BusinessStartingTime]
   , c.value('(BusinessEndingTime/text())[1]', 'datetime') AS [BusinessEndingTime]
   , c.value('(StartingBalance/text())[1]', 'MONEY') AS [StartingBalance]
   , c.value('(EndingBalance/text())[1]', 'MONEY') AS [EndingBalance]
FROM XmlFile CROSS APPLY xmlData.nodes('/ArrayOfSafeEODBalance/SafeEODBalance') AS t(c);


  1. Slet data ved hjælp af get url php-streng

  2. MySQL viser ikke databaser oprettet i phpMyAdmin

  3. Installation af phpMyAdmin på Amazon EC2-instans

  4. oprettelse af en skrivebeskyttet bruger i phpMyAdmin