Discussion:
BCP MS SQL Server data from unix shell script
(too old to reply)
rohan
2006-12-06 07:11:38 UTC
Permalink
hi,
I need to retrieve data from a table from MS SQL database and then
populate sybase database tables from the same. The procedure i thought
of is: -

1. BCP MS SQL data onto a flat file.
2. Read that flat file and BCP in again into Sybase table.

Now all this processing shall take place through a shell script.

Prior to BCP i created a DSN for connecting to the MS SQL database

When i run the BCP command seperately from a command prompt it runs
fine and generates a flat file form the table too. The i also BCPed in
the flat file into sybase table which too went fine.

But the same procedure wont work from a shell script.
If i try to invoke the bcp command from a unix promt it wont connect to
the MS SQL database which i thought it wont, as per my knowledge
Microsoft hasnt come up with a driver for connecting its SQL server
from unix.

Can anybody suggest as to how shall one BCP MS SQL data within a shell
script or for that matter even a perl script?



Rohan
Arthur Green
2006-12-22 15:28:33 UTC
Permalink
Post by rohan
hi,
I need to retrieve data from a table from MS SQL database and then
populate sybase database tables from the same. The procedure i thought
of is: -
1. BCP MS SQL data onto a flat file.
2. Read that flat file and BCP in again into Sybase table.
Now all this processing shall take place through a shell script.
Prior to BCP i created a DSN for connecting to the MS SQL database
When i run the BCP command seperately from a command prompt it runs
fine and generates a flat file form the table too. The i also BCPed in
the flat file into sybase table which too went fine.
But the same procedure wont work from a shell script.
If i try to invoke the bcp command from a unix promt it wont connect to
the MS SQL database which i thought it wont, as per my knowledge
Microsoft hasnt come up with a driver for connecting its SQL server
from unix.
Can anybody suggest as to how shall one BCP MS SQL data within a shell
script or for that matter even a perl script?
You might try looking into FreeTDS and using a Perl script (or similar) to
pull data from the MS-SQL DB.
Post by rohan
Rohan
--
Arthur Green
Loading...