?
Solved

What is the "Provider Name" for foxpro DB when using openrowset in SQL select ?

Posted on 2006-07-21
13
Medium Priority
?
933 Views
Last Modified: 2011-10-03
I'm now writing a two-way query between MS SQL server & foxpro DB.

On MS SQL server, I need to access both tables on SQL server as well as on foxpro DB using SQL select statement.  From the SQL Server Books Online (search Transact-SQL Reference "OPENROWSET"), I can find my expected syntax.  However, in the OPENROWSET command, the first parameter is "provider name" .... I'm now required to access DB in Visual Foxpro 6.0 DB, what is the "provider name" for this ?  Please also, advise how can one search such name ?  Thanks.

Can anyone help ?

Cheers
StanleyLMW
0
Comment
Question by:StanleyLMW
  • 7
  • 6
13 Comments
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17152342
I would suggest you access FoxPro through ODBC.
0
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17152353
In more detail:

Create System DSN

EXEC sp_addlinkedserver
   @server = 'LinkedServerName',
   @provider = 'MSDASQL',
   @datasrc = 'Your System DSN'
0
 

Author Comment

by:StanleyLMW
ID: 17152515
Hi Mr Peerapol,

Actually, I do not insist to use OLE DB, just can complete my job will be fine ^.^

I'm not quite clear on your ODBC method.  I do created an ODBC file DSN to access both for specific SQL server Database (here I name it as SSS.DSN, it access a database named SSS on my SQL server and the connection verified to be OK) and Foxpro DB (here I name it TRANHIST.DSN, it access a folder on my server which contain the related foxpro DBs).

Then, in my stored procedure, I want to access a SQL table named CLIENT under the SQL SSS database and a FOXPRO TRANHIST.DBF under the server folder mentioned above.  What should I do in my stored procedure in order to compose my SELECT statement and to access those tables via ODBC ?  e.g.

SELECT * from xxxxxxxx.CLIENT LEFT OUTER JOIN yyyyyyyyyyy.TRANHIST ON ...............

Kindly please advise.

Cheers
StanleyLMW
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17152559
You don't need to create DSN for SQL Server. Just execute the sp_addlinkedsever above for Foxpro. Then you can do like this:

SELECT c.*, f.*
FROM SSS.dbo.CLIENT c LEFT OUTER JOIN OPENQUERY(LinkedServerName, 'SELECT somefields FROM foxpro_table') f ON ...




0
 

Author Comment

by:StanleyLMW
ID: 17152764
Hi Mr Peerapol,

My company's setting is really more than stubborn ... even in testing environment, they do not allow us to create linked server .... !!!  They say that even in production, they try not to link any SQL servers.  As a result, even I can test it at home and find to be OK, I still can not put it on production .... :(

.... any other methods can be use ?

Regards,
Stanley
0
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17152933
Do they allow you to create DNS? If yes, can you try using OPENROWSET and passing 'MSDASQL' as a provider name?
Otherwise, I'm sorry to say I have no idea.

0
 

Author Comment

by:StanleyLMW
ID: 17165635
Hi Mr Peerapol,

You mean System/User/File DSN ?  Yes.  They allow.  Yet, but using 'MSDASQL' as the provider name can access Foxpro database or not ?  I'm not that familiar with the syntax of OPENROWSET, may you suggest the what I should type into the OPENROWSET as the parameters ?

Cheers
Stanley
0
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17165809
I never tried FoxPro before. So I'm not sure it will work for you.

Create the system DSN first (you should specify username/password here), then try this:

SELECT *
FROM OPENROWSET('MSDASQL', 'DSN_goes_here', 'SELECT somefieds FROM foxpro_table')
0
 

Author Comment

by:StanleyLMW
ID: 17165819
OK .... understand ... let me try and come back to you ...

0
 
LVL 25

Accepted Solution

by:
Mr_Peerapol earned 2000 total points
ID: 17165849
I got this from internet. It might be useful for you. I think no DSN is required by below methods:


SELECT a.*
 FROM OPENROWSET('MSDASQL',
 'DRIVER={Microsoft Visual FoxPro Driver};
 Exclusive=No;Collate=Machine;Deleted=Yes;Null=No;
 SourceDB=d:\data\MyDatabase.dbc;SourceType=DBC;',
 'SELECT * FROM MyTable') AS a


SELECT * FROM OPENROWSET('MSDASQL', 'DRIVER={Microsoft foxpro vfp Driver
(*.dbf)};UID=;Deleted=No;Null=No;Collate=Machine;BackgroundFetch=No;Exclusive=No;SourceType=DBF;SourceDB=c:\abc', 'SELECT * FROM T_MWKNO')
0
 

Author Comment

by:StanleyLMW
ID: 17165871
Nothing can be say .... you are really great !!  I really mean it.

million million thanks.... ... .... ...  ..... thanks.

Cheers
Stanley
0
 

Author Comment

by:StanleyLMW
ID: 17165875
it works and even no DSN required !!  ^_^
0
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17165984
So you need to hard-code the file location.
Anyway, I'm glad that helps.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question