根据条件生成脚本 [英] Generating scripts based on condition
问题描述
通过使用SQL Server Management Studio,可以通过右键单击数据库->任务->生成脚本,选择表并最终仅选择数据来生成某些表的插入.但是,表会随着时间的推移而变大,我只需要具有一定条件的插入项,该条件只会返回该表中的一部分数据.
示例:有一张桌子
FlightTickets
(
TicketId(PK),
BuyerId(FK to buyers),
FlightId(FK to Flights)
)
并且我只需要条件FlightId = 12345的插入脚本.
是否可以在SQL Server Management Studio中完成操作,还是必须用C#编写一些内容来解决这个问题?
您可以尝试数据库->任务->导入数据-> [然后选择源和目标]-> [编写查询以指定数据转移]选项->然后使用过滤器[其中flightid = 12345]编写查询
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?
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]
这篇关于根据条件生成脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!