0
전자 메일을받는 사람 목록에 개별적으로 보내려고합니다. 나는 오류가 발생하고있다 :sp_send_dbmail에서 변수를 사용하여 쿼리를 실행할 때 오류가 발생했습니다.
여기Msg 22050, Level 16, State 1, Line 0
Error formatting query, probably invalid parameters
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 478
Query execution failed: Msg 4104, Level 16, State 1, Server xxxxxx, Line 1
The multi-part identifier "[email protected]" could not be bound.
내 코드의 단순화 된 버전입니다, 표를 asssuming 것은 유효한 기존 테이블 이름과 이메일 기존하는 열입니다.
declare @current_mailaddress varchar(50), @query varchar(1000)
set @current_mailaddress = '[email protected]'
set @query = 'select distinct name, email from table1
where email = ' + @current_email
exec msdb.dbo.sp_send_dbmail
@recipients = @current_email,
@subject = 'test',
@query = @query
그래서 오류에 따르면 서식 지정 (아마도 @query)이 잘못되었습니다. 나는 그것을 이해할 수 없다. 어떤 아이디어?