2011-10-07 6 views
0

나는 삽입이라는 절차를 가지고 같은 코드는 같습니다 퍼팅 결과는 임시 테이블로 설정

Msg 8164, Level 16, State 1, Procedure Gen_Insert, Line 73 
An INSERT EXEC statement cannot be nested. 

이 사람이 나를 도울 수

: 나는 그것을 실행할 때 나는 다음과 같은 오류를 얻고있다

Create procedure Gen_insert 
As 
BEGIN 


create table #temp 
(insert_stmt varchar(max)) 
insert into #temp 
EXEC Generate_Insert @Table = 'Admin' 

insert into #temp 
EXEC Generate_Insert @Table = 'Impas' 

insert into #temp 
EXEC Generate_Insert @Table = 'Asui' 

insert into #temp 
EXEC Generate_Insert @Table = 'Alstd' 

select * from #temp 

End 

.

+2

왜 지구상에 proc의 이름을 'INSERT'라고 지으시겠습니까? – JNK

+0

일반 삽입 proc를 사용하는 대신 올바른 작업을 수행하지 않고 삽입을 쓰는 이유는 무엇입니까? – HLGEM

답변

4

An INSERT EXEC statement cannot be nested. 오류 메시지는 분명합니다. INSERT ... EXEC 중첩 중입니다. 진술. 호출 한 프로 시저 (Generate_Insert)가 다시 INSERT ... EXEC를 사용하거나 insert 프로 시저의 호출자가 INSERT ... EXEC에서이를 사용합니다. 오직 당신 만이 어떤 경우인지 알 수 있습니다. 경험적으로 INSERT ... EXEC는 this and other problems 때문에 피해야합니다.