Sunday, March 25, 2012

Alerts passing info to a job

I'm not sure if this is the right place to post this, but here's my question
.
I have a trigger on a table where if a particular field is updated, I need
to create a file containing some info relevant to the row that was updated.
My initial thought was to raiserror in my trigger and then fire a job from
the alert which will run a select statement to a file, but I don't think it'
s
possible to pass information from my alert to my job to specify which row I
need to select against.
Am I going about this the entirely wrong way? Or is this a possibility?You can just start the job from trigger with sp_start_job. sp_start_job
works asynchronously, so your trigger won't have to wait for the job to
finish before it can complete itself.
Jacco Schalkwijk
SQL Server MVP
"MattBell" <MattBell@.discussions.microsoft.com> wrote in message
news:645BC25A-52AB-4E5F-A74C-7F6232D2C97C@.microsoft.com...
> I'm not sure if this is the right place to post this, but here's my
> question.
> I have a trigger on a table where if a particular field is updated, I need
> to create a file containing some info relevant to the row that was
> updated.
> My initial thought was to raiserror in my trigger and then fire a job from
> the alert which will run a select statement to a file, but I don't think
> it's
> possible to pass information from my alert to my job to specify which row
> I
> need to select against.
> Am I going about this the entirely wrong way? Or is this a possibility?|||Why not call a stored procedure from the trigger? You can pass the data
there and create your file when the trigger is fired..
Regards,
Brad Feaker
Ex nihilo, nihil fit
"MattBell" wrote:

> I'm not sure if this is the right place to post this, but here's my questi
on.
> I have a trigger on a table where if a particular field is updated, I need
> to create a file containing some info relevant to the row that was updated
.
> My initial thought was to raiserror in my trigger and then fire a job from
> the alert which will run a select statement to a file, but I don't think i
t's
> possible to pass information from my alert to my job to specify which row
I
> need to select against.
> Am I going about this the entirely wrong way? Or is this a possibility?|||Hey thanks for the info, works great.
One quick question though, is there anyway to squelch the "Job Started"
output from the sp_start_job?
"Jacco Schalkwijk" wrote:

> You can just start the job from trigger with sp_start_job. sp_start_job
> works asynchronously, so your trigger won't have to wait for the job to
> finish before it can complete itself.
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "MattBell" <MattBell@.discussions.microsoft.com> wrote in message
> news:645BC25A-52AB-4E5F-A74C-7F6232D2C97C@.microsoft.com...
>
>|||No, unfortunately not. But it is only an informational message, so it won't
be picked up by most clients, for example ADO.
Jacco Schalkwijk
SQL Server MVP
"MattBell" <MattBell@.discussions.microsoft.com> wrote in message
news:047C5095-0253-40B8-BBFA-542603136CBD@.microsoft.com...
> Hey thanks for the info, works great.
> One quick question though, is there anyway to squelch the "Job Started"
> output from the sp_start_job?
>
> "Jacco Schalkwijk" wrote:
>

No comments:

Post a Comment