Results 1 to 5 of 5

Thread: Emailing from DOS

  1. #1
    Join Date
    Feb 2010
    Posts
    4

    Emailing from DOS

    Hi,

    What are the steps or code required for creating a email script in DOS. I.e, there are SQL codes to be run using BCP utility and SQLCMD in DOS and if anyone of the code fails a message should be automatically sent to a mail id and if the code run successfully a success message should be sent to the same mail id.

    Thanks,
    Saran.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    You can call msdb..sp_send_dbmail as long as you enabled db mail on sql server.

  3. #3
    Join Date
    Feb 2010
    Posts
    4

    Error handling in SQL Server

    Thank u. How can we check errors in sql. I tried doing the below:

    begin try
    begin transaction
    execute........
    commit transaction
    end try

    begin catch
    select error_message();
    end catch;

    But it threw only errors like if a column is defined as not null and while inserting values into table, if that particular column is given null it threw error. But it does not check for anything else. If the data type is smalldatetime and date format while inserting is something else it did not throw error. The code show throw all the possible errors present in a script. How do we get it? Is it possible?

    Thanks,
    Saran.

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Not expert on coding.

  5. #5
    Join Date
    Jan 2010
    Posts
    37
    Is it possible to post the exact sql that you are running and an example that can be recreated to show your problem? I think that would help with troubleshooting your problem a lot.

Posting Permissions

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