tags:

views:

145

answers:

5

I have just inherited a server application, however it seems that the only copy of the database is corrupt and the working version is gone, so is it possible to find what queries the application is running so I can try to rebuild the tables?

Edit: I have some files with no extensions that I are named the same as the databases, IDK if there is anything that can be done with them but if anyone has any ideas.

The accepted answer seems the most likely to succeed however I was able to find another backup so I have not tested it.

+3  A: 

Turn on SQL query logging and watch what the application asks for.

Jason Cohen
Any advise on how to do this? I'm a LAMP guy and am WAY outside my realm here.
Unkwntech
Use SQL Server Configuration Manager to access the server. (Install e.g. from MSDN.) Then you can edit server properties, including logging properties. Turn on the most verbose log. The log entries themselves are obvious since they are clearly SQL queries.
Jason Cohen
A: 

You could run the UNIX command "strings" on the program to see whether it has embedded sql strings:

http://en.wikipedia.org/wiki/Strings_(Unix)

Chris
+2  A: 

If you have access to either a unix machine, or can install the cygwin utilities (http://www.cygwin.com/), there is a command called 'strings' which will search through any file type and print out any contiguous sequence of character data (might just be ascii). That tool should help you identify the sql queries embedded in the aplication.

Kyle Burton
strings | grep -E 'UPDATE|SELECT|...' would probably work very well. :-)
0124816
+2  A: 

Look for SQL Profiler, which (depending on which version you have) is normally available from the tools menu in query analyzer (isqlw.exe) or management studio (in later versions).

With SQL profiler you can run a trace on the server which can show you which queries are being requested by the application.

Ed Guiness
A: 

You could RegEx the files to search for

  • "SELECT *"
  • "UPDATE *"
  • "DELETE FROM *"
  • "INSERT INTO *"
Nathan Koop
These are applications, that have been compiled.
Unkwntech