I have a Trigger which basically using the INSERTED and DELETED Tables - populates an "Audit" table - with DATE, TIME and various fields. This works fine.
But when I lay the same logic under a Stored procedure to fire every 30 minutes I get the dreaded message ;
"Conversion failed when converting datetime from character string"
The code is the same -
DECLARE @CurrentDate DATETIME
DECLARE @CurrentTime Char(10)
SET @CurrentDate = CONVERT(char(10), GetDate(),126)
Set @CurrentTime = CONVERT(VARCHAR(8),GETDATE(),108)
the fields are the same in the tables -
[Date] [datetime] NOT NULL,
[Time] [char](10) NOT NULL
The Trigger is -
INSERT INTO ([Date],[Time])
SELECT @CurrentDate, @CurrentTime
The Stored Procedure is -
OUTPUT @CurrentDate, @CurrentTime INTO
any help would be appreciated -
SQL 2008 DBA/DBD - MCTS/MCITP
Please don't trust me, test the solutions I give you before using them.