MSSQL - 2 x select into Tabelle mit drop dazwischen funktioniert nicht
Server ist MSSQL 2005. Ich mache ein select into eine Tabelle, mache ein drop der Tabelle und starte erneut ein select into diese Tabelle und bekomme die Fehlermeldung in der vorletzten Zeile, dass die Tabelle schon existiert...-
Ich hab mal ne SQL-Frage...
Beim folgenden SQL funktioniert der erste Teil allein bis einschliesslich zum ersten drop table und der zweite Teil danach auch separat.
Aber will ich beide zusammen ausführen funktioniert es nicht.
Dann bekomme ich immer die Meldung "There is already an object named '#testtmp' in the database Zeile 9 (vorletzte Zeile).
select 'a' as erster, 'b' as zweiter into #testtmp
select * from #testtmp
drop table #testtmp
select 'c' as dritter, 'd' as vierter, 'e' as fünfter into #testtmp
select * from #testtmp
drop table #testtmp
Beim folgenden SQL funktioniert der erste Teil allein bis einschliesslich zum ersten drop table und der zweite Teil danach auch separat.
Aber will ich beide zusammen ausführen funktioniert es nicht.
Dann bekomme ich immer die Meldung "There is already an object named '#testtmp' in the database Zeile 9 (vorletzte Zeile).
select 'a' as erster, 'b' as zweiter into #testtmp
select * from #testtmp
drop table #testtmp
select 'c' as dritter, 'd' as vierter, 'e' as fünfter into #testtmp
select * from #testtmp
drop table #testtmp
Please also mark the comments that contributed to the solution of the article
Content-Key: 168304
Url: https://administrator.de/contentid/168304
Printed on: May 4, 2024 at 08:05 o'clock
3 Comments
Latest comment