Solve your biggest tech problems alongside global tech experts with 1:1 help.
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE TimeDifferenceSecs -- Add the parameters for the stored procedure here @batchnumber int = 99, @vessel varchar(50) = "??", @firstdate as datetime, @lastdate as datetime, @difference as datetime AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here set @firstdate = SELECT top 1 datetimecol from Test_01.Table_1 where batchcol = @batchnumber order by datetimecol ASC set @lastdate = SELECT top 1 datetimecol from Test_01.Table_1 where batchcol = @batchnumber order by datetimecol DES set @difference = Datediff("s",@firstdate,@lastdate) END GO
Join the community of 500,000 technology professionals and ask your questions.