Generating scripts based on condition

2019-08-04 12:18发布

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条回答
Bombasti
2楼-- · 2019-08-04 13:04

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]

查看更多
登录 后发表回答