여기서 교착 상태에 직면하고 있습니다. 문제는 3 개의 다른 임시 테이블을 사용하는 절차를 변경해야한다는 것입니다. 대화 이름을 위해 # temptable1, # temptable2, # temptable3을 허용합니다. 내가 복사/여기에 모든 절차를 붙여하지만 일반적인 생각이있다 할 수없는, 원래 절차 (procedure1는)IF ELSE 문 내에서 임시 테이블 삭제
create table #temptable1
는 다음 선택을 사용하여 나머지 두를 생성하는 과정의 시작 부분에있는 # temptable1를 생성 /이 잘 작동 점,하지만 내가 원하는까지 문
select T.Col
, T.Col2
, T.Col3
into #temptable2
from table1 T
where T.BB>0
select T.Col
, T.Col2
, T.Col3
into #temptable3
from table2 T
where T.BB>0
drop table #temptable1
drop table #temptable2
drop table #temptable3
로는 IF/else 문을 추가하여 절차를 변경하는 것입니다. 나는이 메시지가 새로운 프로 시저를 만들려고 할 때 임시 테이블 if 문 (@ 경우 초 이내에 어디에 따라서, 그런 선이 표시됩니다
Msg 2714, Level 16, State 1, Procedure pPortfoliostest3, Line 412
There is already an object named '#temptable1' in the database.
Msg 2714, Level 16, State 1, Procedure pPortfoliostest3, Line 550
There is already an object named '#temptable2' in the database.
Msg 2714, Level 16, State 1, Procedure pPortfoliostest3, Line 711
There is already an object named '#temptable3' in the database.
을
declare @BBB nvarchar(32)
create table #temptable1
if @BBB='dd'
begin
select T.Col
, T.Col2
, T.Col3
into #temptable2
from table1 T
where T.BB>0 and T.G='FDL'
select T.Col
, T.Col2
, T.Col3
into #temptable3
from table2 T
where T.BB>0 and T.G='FDL'
drop table #temptable1
drop table #temptable2
drop table #temptable3
end
if @BBB='kk'
begin
select T.Col
, T.Col2
, T.Col3
into #temptable2
from table1 T
where T.BB>0 and T.G='FD'
select T.Col
, T.Col2
, T.Col3
into #temptable3
from table2 T
where T.BB>0 and T.G='FD'
drop table #temptable1
drop table #temptable2
drop table #temptable3
end
else
begin
select T.Col
, T.Col2
, T.Col3
into #temptable2
from table1 T
where T.BB>0
select T.Col
, T.Col2
, T.Col3
into #temptable3
from table2 T
where T.BB>0
drop table #temptable1
drop table #temptable2
drop table #temptable3
end
를 볼 수 있습니다 BBB = 'kk'). 나는 다른 조합을 시도했지만 아무 소용이 없습니다. 어떤 팁? 시간 내 주셔서 감사합니다.
코드 시작 부분에'drop table 문을 넣으십시오. ' –
시도해 보겠습니다. – Jespar
nop하지만 어쨌든 고마워요 – Jespar