2011-07-25 6 views
0

この選択クエリは、私がテーブル内の複数の行を更新したいのですが、特定の列の値が別のテーブルに存在しない場合は、

Select * From Location 
where Location.DeviceAddress not in (Select DeviceAddress From Device) order by DeviceAddress desc 

を変更したい列を与えるしかし、この更新クエリ

Update Location 
set DeviceAddress = NULL 
where Location.DeviceAddress not in (Select DeviceAddress From Device) 

は私に次のエラーを与える:

サブクエリは複数の値を返しました。 =、!=、<、< =、>、> =、またはサブクエリが式として使用されている場合は、これは許可されません。 ステートメントが終了しました。あなたのサブクエリの代わりに1つだけ値を返します。この場合には

Update Location set DeviceAddress = NULL where Location.DeviceAddress not in (Select 
top 1 DeviceAddress From Device where Device.DeviceAddress == Location.DeviceAddress) 

をしようとする場合があります、私はいつものように、支援がずっと

答えて

1

を試してみてください、私は無効に(といくつかの時間後に固定)でそれを解決することができたので、このエラーは場所テーブル上の更新トリガーでのクエリによって引き起こされたトリガーをオンにします。私を助けるために時間を割いたすべての人に感謝します。

0

を高く評価され、マイクロソフトServer 2008を使用して、としています参考のため

複数。

0

Update 
    Location 
set 
    DeviceAddress = NULL 
where 
    not exists (Select null From Device where Device.DeviceAddress = Location.DeviceAddress) 
関連する問題