当我用select *
替换delete
时,我在第2行附近遇到语法错误。但我需要这个,因为我在where子句中引用它。那么如何删除此查询的结果?
select *
from [PrimusGroup].[dbo].[PrmsBlotter] t
where t.RunType = 'Backtesting'
and not exists (
select 1
from [PrimusGroup].[dbo].[PrmsBlotter] i
where i.RunType = 'Live'
and i.BBox = t.BBox
and convert(date,i.RunDateStart) = convert(date,t.TestDateFrom)
)
答案 0 :(得分:1)
正如@Gordon Linoff所说,用select *
替换delete t
。
delete t
from [PrimusGroup].[dbo].[PrmsBlotter] t
where t.RunType = 'Backtesting'
and not exists (
select 1
from [PrimusGroup].[dbo].[PrmsBlotter] i
where i.RunType = 'Live'
and i.BBox = t.BBox
and convert(date,i.RunDateStart) = convert(date,t.TestDateFrom)
)