Home Forums Programming General Insert error - convert failed RE: Insert error - convert failed

  • PritamSalvi (1/10/2013)


    I have one more script also to find current running job on the server which i need to insert in the temp table and with using IF else loop i can set email alert notification -

    SELECT top 1 j.name as Running_Jobs, ja.Start_execution_date As Starting_time,

    datediff(ss, ja.Start_execution_date,getdate())/60 as [Has_been_running(in Min)]

    FROM msdb.dbo.sysjobactivity ja

    JOIN msdb.dbo.sysjobs j

    ON j.job_id=ja.job_id

    WHERE job_history_id is null

    AND start_execution_date is NOT NULL and start_execution_date > GETDATE() -1

    and datediff(ss, ja.Start_execution_date,getdate())/60 > 60

    --and j.name like '%gdc%'

    ORDER BY start_execution_date

    Can somebody help me.

    Thanks in advance.

    If this is inserting into a temp table, once done create a sp_send_dbmail script underneath it to check if a row exists in the table and if so email the people who need to know

    INSERT INTO #Temp

    SELECT TOP 1 ...............

    IF @@RowCount > 0

    BEGIN

    EXEC MSDB.dbo.sp_send_dbmail

    .....