Hi
Seems that this posted before I finished typing...
CREATE PROCEDURE MyInsert
AS
BEGIN
DECLARE @stat int, @row_count int
INSERT INTO MyTable (col1...) VALUES (... )
SELECT @stat = @@ERROR, @row_count = @@ROWCOUNT
IF @stat <> 0 RETURN @stat
IF @row_count > 0
EXEC @stat = xp_sendmail .....
RETURN @stat
END
[quoted text, click to view] "John Bell" wrote:
> Hi
>
> If you encapsulate your insert statement in a stored procedure then after
> the insert statement you should check @@ERROR and also saving the value of
> @@ROWCOUNT. You can see if the insert statement returned any rows.
>
> CREATE PROCEDURE MyInsert
> AS
> BEGIN
> DECLARE @stat int, @row_count int
>
> INSERT INTO MyTable (col1...) VALUES (... )
> SELECT @stat = @@ERROR, @row_count = @@ROWCOUNT
> IF @stat <> 0 RETURN @stat
>
> IF @row_count > 0
>
>
> "chinna jambu via SQLMonster.com" wrote:
>
> > i created a query which insert rows in to another table, and send mail to
> > the recepient using sql mail task.
> > the work flow Success is sending mail even 0 rows inserted into the table.
> >
> > Is their any way i can send mail only if row insert in to table?
> >
> > --
> > Message posted via
http://www.sqlmonster.com