|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
A query within xp_sendmailHi, I need to specify a where conditio within a query under xp_sendmail. The
statement is like this: xp_sendmail @recipients='myaddr***@mydomain.com', @query='select * from mytable where clientcode_c='A'' and I got an error Can you tell me where it is wrong? Thanks, I got my guidance for using this extended procedure from:
http://www.sqldev.net/xp/xpsmtp.htm Looking back at that page, I don't see an '@query' parameter. Show quote "qjlee" wrote: > Hi, I need to specify a where conditio within a query under xp_sendmail. The > statement is like this: > xp_sendmail > @recipients='myaddr***@mydomain.com', > @query='select * from mytable where clientcode_c='A'' > and I got an error > > Can you tell me where it is wrong? > > Thanks, xp_sendmail (included in SQL Server) is not the same as xp_smtp_sendmail (an
add-on). Show quote "Kevin Bowker" <KevinBow***@discussions.microsoft.com> wrote in message news:12693670-1564-4798-888D-5605F0206A15@microsoft.com... >I got my guidance for using this extended procedure from: > http://www.sqldev.net/xp/xpsmtp.htm > > Looking back at that page, I don't see an '@query' parameter. > > "qjlee" wrote: > >> Hi, I need to specify a where conditio within a query under xp_sendmail. >> The >> statement is like this: >> xp_sendmail >> @recipients='myaddr***@mydomain.com', >> @query='select * from mytable where clientcode_c='A'' >> and I got an error >> >> Can you tell me where it is wrong? >> >> Thanks, Try escaping the single quotation mark inside the string.
> @query='select * from mytable where clientcode_c='A'' @query='select * from mytable where clientcode_c=''A'''AMB Show quote "qjlee" wrote: > Hi, I need to specify a where conditio within a query under xp_sendmail. The > statement is like this: > xp_sendmail > @recipients='myaddr***@mydomain.com', > @query='select * from mytable where clientcode_c='A'' > and I got an error > > Can you tell me where it is wrong? > > Thanks, qjlee wrote:
> Hi, I need to specify a where conditio within a query under xp_sendmail. It looks like you need to add more single-quotation marks in your query. > The statement is like this: > xp_sendmail > @recipients='myaddr***@mydomain.com', > @query='select * from mytable where clientcode_c='A'' > and I got an error > > Can you tell me where it is wrong? > > Thanks, You need two single quotes before and after the letter A: @query='select * from mytable where clientcode_c=''A''' Ben If you are using xp_smtp_sendmail you can use xp_cmdshell and bcp to write
to a file and then use the @messagefile parameter to show the contents of the file in the table. Be aware of the security implications of xp_cmdshell before you use it. INSERT INTO TABLE1 select * from mytable where clientcode_c='A' EXEC master..xp_cmdshell "bcp DatabaseName.dbo.TABLE1out \\SERVER1\Folder1\TextFile.txt -c -T" exec @rc = master.dbo.xp_smtp_sendmail @to... @from.. @Mmessage... @messagefile = N'\\SERVER1\Folder1\TextFile.txt' .... @query would be a great addition to xp_smtp_sendmail I would even pay for it. Show quote "Ben Amada" <b**@REpoMOweVErpick.com> wrote in message news:u9KfB2%23gFHA.1444@TK2MSFTNGP10.phx.gbl... > qjlee wrote: > > > Hi, I need to specify a where conditio within a query under xp_sendmail. > > The statement is like this: > > xp_sendmail > > @recipients='myaddr***@mydomain.com', > > @query='select * from mytable where clientcode_c='A'' > > and I got an error > > > > Can you tell me where it is wrong? > > > > Thanks, > > It looks like you need to add more single-quotation marks in your query. > You need two single quotes before and after the letter A: > > @query='select * from mytable where clientcode_c=''A''' > > Ben > > "qjlee" <qj***@discussions.microsoft.com> escribió en el mensaje @query='select * from mytable where clientcode_c Like ' + 'A'news:60984BAA-F911-4AB1-B915-337A1E94699B@microsoft.com... > Hi, I need to specify a where conditio within a query under xp_sendmail. > The > statement is like this: > xp_sendmail > @recipients='myaddr***@mydomain.com', > @query='select * from mytable where clientcode_c='A'' Show quote > and I got an error > > Can you tell me where it is wrong? > > Thanks, Thank you.
That two single quotation works. Thank you very much for all your response. Show quote "qjlee" wrote: > Hi, I need to specify a where conditio within a query under xp_sendmail. The > statement is like this: > xp_sendmail > @recipients='myaddr***@mydomain.com', > @query='select * from mytable where clientcode_c='A'' > and I got an error > > Can you tell me where it is wrong? > > Thanks, |
|||||||||||||||||||||||