创建 MSSQL 存储过程来检查 TableA 记录计数。然后将TableA的记录插入到TableB中
希望有人能给我一个如何在 MSSQL 2008/2005 中执行以下操作的一般示例,
我需要在 1 个存储过程中执行以下操作。
我需要它来验证 TableA 是否有超过 1 条记录。 如果 TableA 有多个记录,则:
删除 TableB 中的所有记录并将记录从 TableA 复制到 TableB
为了论证和/或简单起见,TableA 和 TableB 方案是相同的
如果我执行此任务,则不会那么难VB 中的任务,但我试图将这项工作卸载到 SQL 服务器,但我不熟悉如何完成此任务。
Hoping someone can give me a general example of how to do the following in MSSQL 2008/2005
I need to do the following in 1 stored procedure.
I need it to verify TableA has more than 1 record.
If TableA has more than one record then:
Delete all records from TableB AND copy the records from TableA to TableB
For the sake of argument and/or simplicity TableA and TableB Schemes are the same
This task wouldn't be that hard if I was performing the tasks in VB but I am trying to offload this work to the SQL server and I am not familiar on how to accomplish this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试这样的事情:
Try something like this:
我建议查看 SQL Server 集成服务。它旨在执行您正在尝试执行的任务类型。
以下是一些可帮助您入门的链接:
这些使用增量负载进行,这似乎是您想要做的。
I would recommend looking at SQL Server integration services. It is designed to perform exactly the types of tasks you are trying to do.
Here are a couple of links to get you started:
These go over using an Incremental Load which seems to be what you want to do.