Saturday, July 12, 2014

Stop SQL job from commands

Jobs are not stopping when click on stop button of job. so I used follwing command to stop it.



SELECT j.name as jobname
   
              , j.*,ja.*
FROM msdb.dbo.sysjobactivity ja
JOIN msdb.dbo.sysjobs j
    ON ja.job_id = j.job_id
WHERE ja.session_id = (SELECT TOP 1 session_id FROM msdb.dbo.syssessions ORDER BY agent_start_date DESC)
AND start_execution_date is not null
AND stop_execution_date is null;

Step 2-> Copy all rows in Excel.

Step 3-> look the DB name, Job execution time, Job started date etc.

Step 4-> Now select correct SPID and stop it.

USE msdb ; GO EXEC dbo.sp_stop_job N'Job Name' ; GO


--sp_who2
--kill -58-  

Where 58 Is SPID which I want to stop.

Thursday, May 1, 2014

SSRS-Report builder calculate date difference



=Datediff("d", Fileds!fromdate.Value,  now())
below are the list of 'code':
Setting
Description
yyyy
Year
q
Quarter
m
Month
y
Day of year
d
Day
w
Weekday
ww
Week of year
h
Hour
n
Minute
s
Second