Home > Archive > MS SQL Server ODBC > April 2005 > "Linked Table" from a .txt file in SQL Server?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author "Linked Table" from a .txt file in SQL Server?
Joel

2005-04-06, 8:01 pm

OKay, I'm really, really good with MS Access, but am just getting up to speed
on SQL Server. Is there a SQL Server equivalent of linking (not importing) a
table from a .txt file?

Thanks!
Sue Hoegemeier

2005-04-07, 7:01 am

Something similar would be to create a linked server to
access the text file. You use the Jet provider and set the
data source to the directory which has the text files you
want to access.
EXEC sp_addlinkedserver @server ='TextLinkServer',
@srvproduct='',
@provider ='Microsoft.Jet.OLEDB.4.0',
@datasrc='D:',
@provstr='Text'

You could then get a list of all text files in the directory
if you execute:
EXEC sp_tables_ex 'TextLinkServer'

You can access the files as listed in the directory. Use the
table_name listed when you execute sp_tables_ex which is the
text file name.
select *
from TextLinkServer...[YourFile#txt]
to access D:\YourFile.txt

-Sue

On Wed, 6 Apr 2005 16:05:04 -0700, "Joel"
<Joel@discussions.microsoft.com> wrote:

>OKay, I'm really, really good with MS Access, but am just getting up to speed
>on SQL Server. Is there a SQL Server equivalent of linking (not importing) a
>table from a .txt file?
>
>Thanks!


Joel

2005-04-07, 8:01 pm

Almost there....

The only other thing is that I'm trying to use a text file that exports from
SAP, which wants to export to the 'C:\Documents and
Settings\USERNAME\Sa
pWorkDir' directory. When specifying a datasource, is
there a way to use a variable to put in the currently logged on user in place
of USERNAME?

Thanks!

"Sue Hoegemeier" wrote:

> Something similar would be to create a linked server to
> access the text file. You use the Jet provider and set the
> data source to the directory which has the text files you
> want to access.
> EXEC sp_addlinkedserver @server ='TextLinkServer',
> @srvproduct='',
> @provider ='Microsoft.Jet.OLEDB.4.0',
> @datasrc='D:',
> @provstr='Text'
>
> You could then get a list of all text files in the directory
> if you execute:
> EXEC sp_tables_ex 'TextLinkServer'
>
> You can access the files as listed in the directory. Use the
> table_name listed when you execute sp_tables_ex which is the
> text file name.
> select *
> from TextLinkServer...[YourFile#txt]
> to access D:\YourFile.txt
>
> -Sue
>
> On Wed, 6 Apr 2005 16:05:04 -0700, "Joel"
> <Joel@discussions.microsoft.com> wrote:
>
>
>

Sue Hoegemeier

2005-04-11, 7:23 am

If the data source is always changing and varies from user
to user, you may want to look at using Openrowset instead.

-Sue

On Thu, 7 Apr 2005 07:33:05 -0700, "Joel"
<Joel@discussions.microsoft.com> wrote:
[color=darkred]
>Almost there....
>
>The only other thing is that I'm trying to use a text file that exports from
>SAP, which wants to export to the 'C:\Documents and
> Settings\USERNAME\Sa
pWorkDir' directory. When specifying a datasource, is
>there a way to use a variable to put in the currently logged on user in place
>of USERNAME?
>
>Thanks!
>
>"Sue Hoegemeier" wrote:
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com