Solved

Record User ID SQl 2008

Posted on 2013-01-03
2
396 Views
Last Modified: 2013-01-03
Hello,

I'm new to SQL, but I'm trying to transition an access database that used linked tables in SharePoint to an Access front end that uses linked tables in SQL2008 server.

I've used the Access Upscale facility to move the linked tables to a SQL database ... which all worked ok.

I had a problem that the fields that sharepoint used to populate automatically i.e Date modified / created  didn't automatically populate. I've solved this now by using triggers to inset the date depending on if the record is updated / inserted.

The problem I have now is how I go about capturing the USER ID and inserting that into Created By / Modified by... Sharepoint was linked to the AD Address book so was able to resolve the users actual name.

Is it possible to capture this data using a trigger also? - I could pass it as part of the sql statement but would ratehr have the server handle this part to remove the possibility of manipulation.

Thanks
0
Comment
Question by:bedsingar
2 Comments
 
LVL 15

Accepted Solution

by:
Anuj earned 500 total points
Comment Utility
Use SYSTEM_USER, in your inserts or add default  values  "SYSTEM_USER" to creatdby and modifiedby columns .
0
 

Author Comment

by:bedsingar
Comment Utility
Ah yes...

Went with:  

UPDATE dbo.API_EVENT_LOG
    SET [Modified By] = SYSTEM_USER
    WHERE ID IN (SELECT DISTINCT ID FROM Inserted)

So that the modified by updates by the created by stays the same.

Thanks
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now