sql >> Databáze >  >> Database Tools >> SSMS

Získání XML pro vstup do SQL Server tabulky

Zde je upraveno funkční SQL. Až budete připraveni, stačí odkomentovat řádky INSERT.

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. Neplatný počet polí ve vstupu CSV na řádku 1 phpmyadmin

  2. phpMyAdmin Není vybrána žádná databáze MySQL

  3. MySQL #2006 - MySQL server v phpMyAdmin zmizel

  4. Integrace pracovního stolu Drool 6 s aplikací Java