To my knowledge, there is no
WHERE clause when generating scripts (assuming you are using Right-click->Tasks->Generate Scripts).
Without knowing your use case it's hard to give you an accurate answer, but one way is to:
- Create a staging database that you are going to export from
- Select all the tables into new tables with the same names into the staging database from the original database with the
- Export that database by generating scripts.
Since you used the same table name, you only have to change the database name in the generated script (using Ctrl+H).
This is tedious since you have to define the
WHERE clause for each table, but you would have to do it if Generate Scripts feature had a
WHERE clause anyway. Unless all your tables have a common column you are filtering by, in which case you can use
sys.tables to generate the
SELECT 'SELECT * FROM ' + QUOTENAME(name) + ' WHERE <column> = value'