Generating scripts based on condition

核能气质少年 提交于 2020-01-05 09:08:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!