Learn when you want, where you want with convenient online training courses. Sign up now!
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
CREATE TABLE [dbo].[core_Audit](
[ID] [bigint] IDENTITY(1,1) NOT NULL,
[ObjectID] [int] NOT NULL,
[TableName] [nvarchar](50) NOT NULL,
[FieldName] [nvarchar](50) NOT NULL,
[SourceID] [uniqueidentifier] NOT NULL,
[DataType] [varchar](50) NOT NULL,
[OldValue] [nvarchar](255) NOT NULL,
[NewValue] [nvarchar](255) NOT NULL,
[UserModified] [int] NOT NULL,
[DateModified] [datetime] NOT NULL CONSTRAINT [DF_core_Audit_DateModified] DEFAULT (getdate()),
CONSTRAINT [PK_core_Audit] PRIMARY KEY CLUSTERED
Open in new window
INSERT INTO dbo.core_Audit ( ObjectID , TableName , FieldName , SourceID ,DataType ,OldValue ,NewValue ,UserModified ,DateModified)
SELECT 22, 'core_Order', 'OrderNumber', t1.GID, 'varchar (50)', LEFT(ISNULL(CAST(t2.OrderNumber AS NVARCHAR(4000)), 'NULL'), 255), LEFT(ISNULL(CAST(t1.OrderNumber AS NVARCHAR(4000)), 'NULL'), 255), t1.UserModified, @Date
FROM INSERTED t1 INNER JOIN DELETED t2 ON t1.ID = t2.ID
WHERE ISNULL(t1.OrderNumber, '') <> ISNULL(t2.OrderNumber, '')
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.