我可以在 SQL Server 2008 中使用所选值生成 INSERT 语句吗?
如果我从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,这是不可能的。
据我所知,与此最接近的是 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.您可以使用触发器将已删除或更新的行插入到您创建为备份表的其他表中,以便您始终可以将特定行重新插入到原始表中。
很简单,您需要某种方法来备份受影响的数据。
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.