从选择的结果创建插入脚本
使用 SQL Server Management Studio 有一种方法可以在选择结果网格中选择一行或多行,并让 SQL Server Mangement Studio 生成一个或多个插入语句(每选择一行一个),该语句会将该数据插入到表中相同的架构?
编辑:我知道如何手动创建一个,但我希望有一些东西可以自动为我创建它。如果您熟悉 Toad,有一种方法可以让 Toad 根据结果窗格中的数据生成插入,我希望 SSMS 具有等效的功能。
Using SQL Server Management Studio is there a way I can select one or more rows in the grid of select results and have SQL Server Mangement Studio generate one or more insert statements (one for each row selected) which would insert that data into a table with the same schema?
Edit: I know how to create one manually, but I was hoping there would be something that would create it automatically for me. If you are familiar with Toad there is a way to have Toad generate inserts based on data in the results pane and I was hoping SSMS had an equivalant function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试将查询结果保存到一次性表中。
例如:
SELECT * INTO disposable_customer_table FROM customer_table WHERE id IN (in range of Something)
然后执行 db ->;任务->生成脚本。
调整结果文件并将 disposable_customer_table 重命名回原始表名称。
清理它并删除disposable_customer_table。
Try to save the query result into a disposable table.
For example:
SELECT * INTO disposable_customer_table FROM customer_table WHERE id IN (in range of something)
Then do a db -> Tasks -> Generate Scripts.
Tweak the result file and rename the disposable_customer_table back to the original table name.
Clean it up and drop the disposable_customer_table.
我认为您有两个选择:
手动创建插入内容。例如:
这将为您提供结果,并在最后一列中提供该行的插入脚本。然后您可以选择它并将其粘贴到编辑器窗口中。
右键单击数据库 ->任务->生成脚本。按然后前进并选择“仅数据”(默认为仅架构)。
I think you have two options here:
Create your inserts manually. For instance:
This gets you the results and, in the last column, the insert script for the row. You can then select and paste it in an Editor window.
Right click on the db -> Tasks -> Generate Scripts. Press then Advance and select "Data Only" (Default is Schema Only).
执行查询并右键单击“结果”视图中列标题与行号相交的空白区域。
然后,您可以选择脚本网格结果:
Perform your query and right click on the blank area where the column headers meet the row number in the Results view.
You can then select Script Grid Results: