ShreyaTrivedi
asked on
Sql Query for reading a comma delimited textfile
I want Sql query which can read a comma-delimited text file and create a table for it. I know that it can be done using loop by reading line by line. But I want a query which can directly do the task. I had found that query which can directly read a delimited textfile and create a table for it. But it has been misplaced. That was a direct sql query which also created a table alongwith reading the file. I want that query.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Hi,
try this:
INSERT INTO TableName
SELECT *
FROM OPENROWSET('Microsoft.Jet. OLEDB.4.0' , 'Text;Database=C:\TEST\;',
'SELECT * FROM test1.csv')
try this:
INSERT INTO TableName
SELECT *
FROM OPENROWSET('Microsoft.Jet.
'SELECT * FROM test1.csv')
ASKER
The following query works-
bulk insert txtTable from 'c:\test\test.txt' with (FieldTerminator=',')
bulk insert txtTable from 'c:\test\test.txt' with (FieldTerminator=',')
ASKER