How to gather SQL Server tables via Scripting?
In some scenarios, troubleshooting database issues might require a lot of time. In rare scenarios, the support engineer might require specific tables.
Important note: Make sure the shared data does not contain sensitive information or anonymize data before sending the file.
This is useful when fewer tables with their data need to be shared. For larger data transfer or full db transfer, the backup tools are more suitable.
- Right-click on the database and select Tasks > Generate Scripts
- On the Choose Objects page, select ‘Select specific database objects’ and expand the Tables
- Select all the needed tables and click Next
- On the Set Scripting Options page, select ‘Save to file’, Files to generate: Single file and File name: path where the current user has write access and click Advanced
- On Advanced Scripting Options new window, make sure to select "Types of data to script" > "Schema and data" and press OK
- Back on the Set Scripting Options page, select Next
- On the Summary page review your selections and select Next
- In the file selected on point 4, script.sql file will be generated