RE: SQL trigger.

RE: SQL trigger.

 

  

SQL Server 200 does not support the use of undeterministic functions, e.g.
GETDATE(), inside Trigger definitions.


>===== Original Message From [Email Address Removed] =====
>Good day everyone!
>
>I have a problem with a trigger.
>
>I created a trigger to insert the current date into a filed if no date as
>been specified. For some reason it does not work.
>
>Here is how it look:
>
>CREATE TRIGGER GETDATE ON docsadm.PROFILE
>FOR INSERT,UPDATE
>AS
>
>UPDATE DOCSADM.PROFILE
>SET DOCNAME = 'Document No.' + ' ' + CONVERT(varchar(24), (DOCNUMBER))
>WHERE DOCNAME = ''
>
>DECLARE @MYDATE DATETIME
>DECLARE @MYSTRING VARCHAR(11)
>SELECT @MYSTRING = CONVERT(VARCHAR, GETDATE())
>SELECT @MYDATE = CONVERT(DATETIME, @MYSTRING)
>
>UPDATE DOCSADM.PROFILE
>SET document_date = @MYDATE
>WHERE document_date = 'JAN 1 1753'
>
>Can anyone tell me why it does not work?
>If I place the trigger in it freeze the application.
>
>
>
>Thanks


MS Sql Server LazyDBA home page