为什么我不能从临时表中删除行?
DECLARE @tbl2 TABLE
(
Id int,
ImieNazwisko varchar(200),
Pesel varchar(200),
Kod varchar(200)
)
DELETE FROM @tbl2 tblT WHERE tblT
SELECT * FROM @tbl2
这也不起作用:
DELETE FROM @tbl2 WHERE @tbl2.Id
您可以从临时表中删除。只是您的语法似乎错误。
尝试这个:
--drop table #temptable
create table #temptable (Id int)
insert into #temptable
select 1 union
select 2 union
select 3
delete from #temptable
where Id =2
select Id from #temptable
DECLARE @tbl2 TABLE
(
Id int,
ImieNazwisko varchar(200),
Pesel varchar(200),
Kod varchar(200)
)
DELETE FROM @tbl2 tblT WHERE tblT.ID = 1 --- for single row delete
SELECT * FROM @tbl2
--从您的情况来看,您想从表中删除所有数据,我认为应该是
delete from @tbl2 -- only
DELETE T (SELECT * FROM @tbl2) T WHERE T.Id = 1
drop table if exists Locations;
Create temporary table Locations
SELECT au_lname, au_fname,
CASE
WHEN state = "CA" or state = "AZ" THEN "west side"
WHEN state = "UT" or state = "MI" or state = "TN" THEN "mid US"
ELSE "east side"
END AS LocationInTheUS
FROM authors
order by LocationInTheUS desc;
delete from Locations where au_lname = " ";
select * from Locations;