问题
The inserts of a certain table(s) can be generated by using SQL Server Management Studio by right clicking on the database -> tasks -> generate scripts, choosing the tables and finally selecting data only. However the table gets bigger with time and I need only the inserts with a certain condition which would only return only a part of the data in that table.
Example: there is a table
FlightTickets
(
TicketId(PK),
BuyerId(FK to buyers),
FlightId(FK to Flights)
)
and I only need the insert scripts with condition FlightId = 12345.
Is it possible to be done in SQL Server Management Studio or do I have to write some in C# to deal with that?
回答1:
You can try database -> tasks --> Import Data --> [then choose source and destination]--> [write a query to specify the data to transfer] option --> then write your query with filter [ where flightid=12345]
来源:https://stackoverflow.com/questions/25339318/generating-scripts-based-on-condition