Text file as data source

In many application we need Text file as data source or as table

many ways to do this one of that as follows

create one folder on c drive name textfiles
and execute following code

EXEC sp_addlinkedserver txtdatasrc, 'Jet 4.0',
'Microsoft.Jet.OLEDB.4.0', 'c:textfiles', NULL, 'Text'

now your link server with name ” txtdatasrc” is created

execute following code

EXEC sp_tables_ex txtdatasrc

see there is no record because folder does not contain any text file .

add new text file name table1 to folder

and again run command

EXEC sp_tables_ex txtdatasrc

see there is table name “table1#txt” in out put

now you can select rows from table1#txt by using select statement as follows

select * from txtsrv...table1#txt

this link server is very useful to access text as data source

there are many other methods and tricks in this stuff we will discuss soon…

Leave a Reply

I'm Yogesh Kadvekar, a Technology Consultant, Computer Engineer by education, tech writer and problem solver. I love startups. I love hiking, sports, arts and Stock market. Say hello!

%d bloggers like this: