Question : Add Milliseconds to Datetime

I have an external system that will be calling my SP with a datetime value, and with a milliseconds value that I want to add to that datetime value as I insert it into my database.

Currently, I have this, which does not add the 2 values together.  Can someone help me with whatever CAST or CONVERT call I need to make in order to add these 2 values together either just before or as I insert the timestamp into the table?

Thanks very much.
===========================================
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[spInsertEvent]
   @TransactionTimestamp datetime = NULL,
   @TransactionMilliseconds int = NULL,
   @DatapointName varchar(64) = NULL,
   @EventValue int = NULL
AS
BEGIN
   INSERT INTO Events
      (TransactionTimestamp, DatapointName, EventValue)
      VALUES
      (@TransactionTimestamp + @TransactionMilliseconds, @DatapointName, @EventValue)

   DECLARE @return_value int
   SET @return_value = 0
END
GO

Answer : Add Milliseconds to Datetime

ALTER PROCEDURE [dbo].[spInsertEvent]
   @TransactionTimestamp datetime = NULL,
   @TransactionMilliseconds int = NULL,
   @DatapointName varchar(64) = NULL,
   @EventValue int = NULL
AS
BEGIN
   INSERT INTO Events
      (TransactionTimestamp, DatapointName, EventValue)
      VALUES
      (DateAdd(ms,@TransactionMilliseconds, @TransactionTimestamp ), @DatapointName, @EventValue)

   DECLARE @return_value int
   SET @return_value = 0
END
Random Solutions  
 
programming4us programming4us