일반적으로 select 문을 사용하면 출력이 표시되지만 insert into를 사용하면 임시 테이블에 결과가 저장됩니다 .i 둘 다 수행하려고합니다. . 결과를 표시하고 동적 테이블에 임시 테이블에 저장하십시오.출력을 표시하고 ms-sql의 전역 임시 테이블에 저장하는 방법
IF @DisplayInSelect IS NOT NULL
SET @DisplayInSelect = ','[email protected]
SET @SQL = 'IF EXISTS (SELECT DISTINCT a.'[email protected]_name+' FROM ['[email protected]+'] a where '[email protected]+')'+
'SELECT DISTINCT ''Error at column: '[email protected]_name+''' as [Error Records if found any are shown below],'''+ISNULL(@CustomErrorMessage,'ERROR')+''''+ISNULL(@DisplayInSELECT,'')+', a.'[email protected]_name+',* FROM ['[email protected]+'] a where '[email protected]+'
INSERT INTO ##error_check(SELECT DISTINCT ''Error at column: '[email protected]_name+''' as [Error Records if found any are shown below],'''+ISNULL(@CustomErrorMessage,'ERROR')+''''+ISNULL(@DisplayInSELECT,'')+', a.'[email protected]_name+', *FROM ['[email protected]+'] a where '[email protected]+');
PRINT('IQR1 sql is'[email protected])
EXEC(@SQL)
END
코드 샘플의 관련성을 얻지는 못합니다. http://stackoverflow.com/help/mcve –