我可以在 SQL Server 2008 中使用所选值生成 INSERT 语句吗?

发布于 2024-12-21 08:30:53 字数 227 浏览 0 评论 0原文

如果我从 SQL Server Management Studio 2008 的结果窗格中选择整行,是否有办法自动创建一个 INSERT 语句脚本,可以使用所选行的值插入新行?

想法是,当我删除该行时,我可以使用生成的 INSERT 语句再次重新插入同一行。

基本上,不要创建空白插入,而是使用 VALUES (val1,val2,val3...) 创建一个脚本,其中值来自所选行。

If I am selecting a whole row from the Results pane of the SQL Server Management Studio 2008, is there a way to create an INSERT statement script automatically that can INSERT a new row with the selected row's values?

Idea is, when I delete that row, I can use the generated INSERT statement to re-insert the same row again.

Basically instead of creating a blank INSERT, create a script with VALUES (val1,val2,val3...) where the values comes from the selected row.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅紫色的梦幻 2024-12-28 08:30:53

不,这是不可能的。

据我所知,与此最接近的是 SSMS Tools Pack Addin “Script Grid Results” 功能。

这将为整个结果网格生成 INSERT 语句到 #temp 表。

No this isn't possible.

Closest thing to this that I am aware of is the SSMS Tools Pack Addin "Script Grid Results" feature.

This will generate INSERT statements to a #temp table for the whole results grid.

入怼 2024-12-28 08:30:53

您可以使用触发器将已删除或更新的行插入到您创建为备份表的其他表中,以便您始终可以将特定行重新插入到原始表中。

很简单,您需要某种方法来备份受影响的数据。

You can use a trigger that will insert deleted or updated row into other table you created as backup table, so you always can re-insert specific row back to original table.

Simple, you need some way to backup your affected data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文