Sha1395
asked on
SQL question regarding UPdatedBY or CreatedBY
HEY All,
I have a column in my Table UpdatedBY or CreatedBY,here i want to insert my appliation name whenever the row is inserted or updated.
i found this link but still am not understand the whole concept
http://stackoverflow.com/questions/323494/sql-server-modifying-the-application-name-property-for-auditing-purposes
some one will help me is much appreciated
I have a column in my Table UpdatedBY or CreatedBY,here i want to insert my appliation name whenever the row is inserted or updated.
i found this link but still am not understand the whole concept
http://stackoverflow.com/questions/323494/sql-server-modifying-the-application-name-property-for-auditing-purposes
some one will help me is much appreciated
By Application name you mean your desktop/web application name or just the database object owner?
ASKER
Hi Grey128,
Am trying to insert database object owner value, it think "CONTEXT_INFO" am not sure.
Thanks in Advance for your help
Am trying to insert database object owner value, it think "CONTEXT_INFO" am not sure.
Thanks in Advance for your help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks grey128
Am trying to insert my application name,but gone thru msdn i found i can do thru CONTEXT INFO.
Am trying to insert my application name,but gone thru msdn i found i can do thru CONTEXT INFO.
ASKER
DECLARE @CONTEXT_INFO varbinary(128)
select @CONTEXT_INFO = cast('WebService' + space(128) as binary(128))
please guide me a going on right path ?
select @CONTEXT_INFO = cast('WebService' + space(128) as binary(128))
please guide me a going on right path ?
ASKER
This is the value am getting
0x444C41576562536572766963 6520202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 2020202020 20.
0x444C41576562536572766963
ASKER
DECLARE @CONTEXT_INFO varbinary(128)
select @CONTEXT_INFO = cast('WebService' + space(128) as binary(128))
update [Employment] set EmployeeNo = @EmployeeNo, OriginalHireDate = @OriginalHireDate, TerminationDate=@TerminationDate,ServiceDate=@ServiceDate,BusinessTitle=@BusinessTitle, CreatedBy=@CONTEXT_INFO,DateUpdated=getdate() where EmployeeNo = @EmployeeNo
End
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey Grey128
Thanks again,i just want to use in built context info in my code.
But i just seen one example i was following the same,in a result i got the above code.
so what i suppose to modify in my code if want to use Context Info ?
Thanks again,i just want to use in built context info in my code.
But i just seen one example i was following the same,in a result i got the above code.
so what i suppose to modify in my code if want to use Context Info ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.