Slightly more compact and only one call to
CURRENT_TIMESTAMP, you can use
CONVERT with its format switch (121) and
REPLACE to tidy up. This reduces the statement from six individual function calls to four. You can also use
FORMAT, which is only two function calls:
REPLACE( TRANSLATE( CONVERT( CHAR(23), CURRENT_TIMESTAMP, 121 ), '-:.', ' ' ), ' ', '' ) c1,
FORMAT( CURRENT_TIMESTAMP , 'yyyyMMddHHmmssfff' ) c2
I would query the need to store these values however. You probably should be storing a conventional timestamp for event records so why also store this form of timestamp in an encoded fashion which you have to unpack if you want to use? Logging to a table with an identity column has a similar effect. Something to think about.