Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Parse MSSQL .bak file

by gryphon (Abbot)
on Dec 05, 2002 at 21:43 UTC ( #217918=note: print w/replies, xml ) Need Help??

in reply to Parse MSSQL .bak file

In the world of total illogic which is that of our client, the requirement that required the data from this massive 2.9 gig BAK file is no longer required. However, I had nearly solved the problem based on all your suggestions. I downloaded a copy of MSSQL 2K Trial and was in the process of dumping the database into a more negotiable format. I originally tried MSDE, but you're limited to databases smaller than 2 gig.

Getting back to Perl, though: Looking through the BAK file in a hex editor, I found it difficult to see many patterns. I concure that it would be very non-trivial to write a Perl parser for such files. However, it ought to be do-able. If anyone had the time and interest, I'm sure folks who like MySQL or PostgreSQL would be fans of a utility that would let them easily migrate an MSSQL database into something a little more open source.

code('Perl') || die;

Replies are listed 'Best First'.
Re: Re: Parse MSSQL .bak file
by mpeppler (Vicar) on Dec 05, 2002 at 23:00 UTC
    Well - if the server is running it should be fairly straightforward to copy the data to flat files. I understand that MS in its infinite wisdom has deprecated the bcp utility, but I've used the following with Sybase:

    #!/usr/bin/perl -w use strict; use Sybase::Simple; my $dbh = new Sybase::Simple 'sa', 'pwd', 'server'; my $tables = $dbh->ArrayOfScalar(" select name from $db..sysobjects where type = 'U'"); foreach my $tab (@$tables) { system("bcp $db..$tab out $tab.bcp -c -Usa -Ppwd -Sserver"); }
    A similar script should be feasible with MS-SQL, either using MS's native tools, or using functionality from the FreeTDS project.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://217918]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2020-11-24 21:58 GMT
Find Nodes?
    Voting Booth?

    No recent polls found