Posts

Showing posts from July, 2009

FindOut StartTime and EndTime in JobHistory

SELECT Job_ID, CONVERT(DATETIME, RTRIM(run_date)) + ((run_time/10000 * 3600) + ((run_time%10000)/100*60) + (run_time%10000)%100 /*run_time_elapsed_seconds*/) / (23.999999*3600 /* seconds in a day*/) AS Start_DateTime , CONVERT(DATETIME, RTRIM(run_date)) + ((run_time/10000 * 3600) + ((run_time%10000)/100*60) + (run_time%10000)%100) / (86399.9964 /* Start Date Time */) + ((run_duration/10000 * 3600) + ((run_duration%10000)/100*60) + (run_duration%10000)%100 /*run_duration_elapsed_seconds*/) / (86399.9964 /* seconds in a day*/) AS End_DateTime , ((run_duration/10000 * 3600) + ((run_duration%10000)/100*60) + (run_duration%10000)%100 /*run_duration_elapsed_seconds*/), GETDATE(), USER_NAME() FROM msdb.dbo.sysjobhistory SELECT * FROM master.dbo.JobsExecutionLog

DELETE FROM

The below example will explain about the How Delete works when we join two tables and delete the values. declare @Table table (sno INT,[Name] varchar(25)) insert @Table values(1,'Ramesh') insert @Table values(2,'Suresh') select * from @Table declare @table2 table (OrderID int,ItemName varchar(30),Sno INT) INSERT @table2 VALUES(1,'Idli',1) INSERT @table2 VALUES(2,'Chapathi',4) SELECT * FROM @table2 DELETE FROM @table2 FROM @table2 as T2 INNER JOIN @Table AS T ON T2.Sno=T.Sno SELECT *from @table2