【问题标题】:Call stored procedure for each item where not exists为每个不存在的项目调用存储过程
【发布时间】:2014-03-14 08:38:48
【问题描述】:

我有以下

delete from Listing
where not exists
(
   select 1
   from ComparitiveListings
   where Listing.ListingKey = ComparitiveListings.ListingKey
 )

但我真正想要做的是执行一个存储过程,MySproc 用于表LISTING 中的每个ListingKey,但在ListingKey 列的表COMPARITIVELISTINGS 中找不到。

我在想一定有一种带有光标的方法,但我不确定?有人在这个吗?

【问题讨论】:

  • 抱歉,Microsoft SQL 专用,最新

标签: sql sql-server loops stored-procedures cursor


【解决方案1】:
Create proc myProc
As
BEGIN
delete from Listing
    where ListingKey not in
    (
       select ListingKey
       from ComparitiveListings

     )
END

【讨论】:

  • MySproc 存储过程调用在哪里?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-09-24
  • 2021-07-30
  • 2013-11-23
  • 2012-06-15
  • 1970-01-01
  • 2014-09-17
相关资源
最近更新 更多