To remove SharePoint Server 2007 from the server entirely, simply uninstall the product using Add/Remove Programs in Control Panel. The setup program that uninstalls the program modifies the configuration database and reverses other modifications accomplished during the installation, including changes made to IIS 6.0. In the case of a Basic or Stand-alone installation using SQL Embedded, SQL Embedded is uninstalled as well but the SQL client tools remain.
With Add/Remove Programs, the product is uninstalled, including all program files except for those that might contain custom information. The following program files however are not removed:
Noise word and thesaurus files
Webconfig files for applications
Index files
Database files, including the configuration database
These files remain in their original locations, so the directory structure remains as well. This allows the farm to be rebuilt using another server and the same databases, files, and index.