问题
I am trying to achieve this kind of formatted data from my select statement and have it send via database mail in SQL SERVER 2000. I know how to do this in SQL 2008.
Column1 | Column 2
------------------
Value 1 | Value 2
Value 1 | Value 2
Value 1 | Value 2
回答1:
I have realized that this can not be done. To achieve this I created .bat file and stored procedures and sendmail utility.
First call this in your .bat file
osql -S %ServerName% -d %dbname% -U %username% -P %password% -Q "EXEC " -o %TempFile1% -s "|" -w 5000 >>%logfile%
and then call
C:\Tools\SendEmail\sendEmail.exe -f -t -u "[%ServerName%] Number of Records Processed: %lineCount%" -m "Data File Generated: %DataFile%" -a %DataFile% -s
来源:https://stackoverflow.com/questions/10037777/send-dbmail-from-sql-server-2000-with-tabular-structured-data