Thursday, November 29, 2018

How to generate sql scripts for SQL Server Database without its organisation data or information


There may be few scenario where we want to mimic our (production) database structure in some other local environment so that development team can proceed with their integration or development activity.

We defiantly do not want to share our data or information for security reason.
However, there could be a possible reason that we might be storing some configuration data that development team might be interested in it.

For an example Employee Designation or Rank, various type of leaves.

Please note: For security reason few of the images are been altered to hide the server and credential details

  1. Go and open SQL Management Studio.
  2. Connect to your Database Server.
  3. Expand the list of Databases from Object explorer.
  4. Right click the desired Database and navigate to Tasks -> Generate Scripts…
  5. The above action will launch the Generate and Publish Scripts wizards. Proceed with next button.
  6. Select the option for Script the entire database and all database objects and proceed with Next button.
  7. Choose output type to Save scripts to a specific location.
  8. Choose option to Save to file. Enter manually the file name with extension .sql as depicted in below image. This is the location where generated script will be saved.
  9. Proceed further by clicking on the next button.
  10. Review your selections and click on the next button to proceed.
  11. You should see the generation of scripts began and it may take a while depending upon the complexity of database metadata.
  12. Click on Finish button and locate the file on the destination folder choose in one of the above steps.


No comments: