Results 1 to 8 of 8

Thread: Sql Mail

  1. #1
    Join Date
    Sep 2003
    Posts
    30

    Sql Mail

    I have this command:

    Exec Master..xp_SendMail
    @recipients = @recipientslist,
    @subject = @subj,
    @message = @msg,
    @query = ''Select * FROM DatabaseName.user.TableName''

    But it gives me an error on the @query command. If I try the same thing without the @query command it works fine. How do I get the query to show in the mail as well?

    Thanks

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Do you have permission on the table?

  3. #3
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    use single quote for the query, double quote has special meaning if you have set quoted identifier to true.


    Exec Master..xp_SendMail
    @recipients = @recipientslist,
    @subject = @subj,
    @message = @msg,
    @query = 'Select * FROM DatabaseName.user.TableName'

  4. #4
    Join Date
    Sep 2003
    Posts
    30
    Yes I have permission to the table. I'm in the adminsitrator group and the using the single quote in @query still gives me this error:


    ODBC error 8198 (42000) Could not obtain information about Windows NT group/user 'domain\username'.

  5. #5
    Join Date
    Sep 2002
    Posts
    5,938
    What permission does your windows account have on target db and table? Member of dbo or something else? Get any result if run 'Select * FROM DatabaseName.user.TableName' alone?

  6. #6
    Join Date
    Sep 2003
    Posts
    30
    I can 'Select * from tablename' on QA just fine.

  7. #7
    Join Date
    Sep 2002
    Posts
    5,938
    What's sql server service account? Does the account have permission on the table?

  8. #8
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Did you create a mail profile for the sql server service account in outlook?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •