Skip to main content

import data in CSV,XML AND XLS into a table

XML

INSERT INTO TABLE_NAME_1 (ID,NAME)
SELECT
 C3.VALUE('ID[1]','INT') AS ID,
 C3.VALUE('NAME[1]','VARCHAR2(10)') AS NAME
 FROM
 (SELECT CAST(C1 AS XML)
 FROM OPENROWSET
 (BULK 'FILE PATH',SINGLE_BLOB) AS T1(C1))AS T2(C2)
CROSS APPLY C2.NODES('/TABLE_NAME/TABLE_NAME') T3(C3); 


CSV

BULK
INSERT TABLE_NAME_1 FROM 'FILE PATH'
WITH
  ( FIELDTERMINATOR=',', FIRSTROW=2, ROWTERMINATOR='\n'
  );


XLS

INSERT INTO TABLE_NAME_1
SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;DATABASE=FILE PATH;', 'SELECT * FROM [SHEET1$];');

Comments

Popular posts from this blog

Behavior Driven Development

Behavior Driven Development (BDD) is a development process that originally associated with Test-Driven Development (TDD).  BDD is written in a readable format in an understandable language for anyone involved in software development.  BDD Features Providing better readability and visibility.  Verifying the software against customer requirements.  Assure the implementation of the system is correct. Derives examples of different expected behaviors of the system. Uses examples as acceptance tests. Focus on customer requirements throughout the development. BDD Practice There are two practices in BDD:-  Specification by Example (SbE). Test-Driven Development (TDD). Specification by example (SbE) uses examples in conversation to illustrate the business rules and the behavior of the software.  This uses to have a better understanding for Business Analyst, Product Owners, Testers and the Developers to reduce the misunderstanding abou...