Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Temporary table delete row

Tags:

sql

tsql

Why I can't delete row from temporary table?

DECLARE @tbl2 TABLE
    (
    Id int,
    ImieNazwisko varchar(200),
    Pesel varchar(200),
    Kod varchar(200)
    )

DELETE FROM @tbl2 tblT WHERE tblT
SELECT * FROM @tbl2

also this doesn`t work:

DELETE FROM @tbl2 WHERE @tbl2.Id
like image 248
Rafał Developer Avatar asked Dec 12 '22 15:12

Rafał Developer


1 Answers

You can delete from a temprorary table. It's just your syntax seems wrong.

Try this:

--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 
like image 138
Semih Yagcioglu Avatar answered Dec 30 '22 09:12

Semih Yagcioglu