Record User ID SQl 2008

Posted on 2013-01-03
Last Modified: 2013-01-03

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.

Question by:bedsingar
LVL 15

Accepted Solution

Anuj earned 500 total points
ID: 38740040
Use SYSTEM_USER, in your inserts or add default  values  "SYSTEM_USER" to creatdby and modifiedby columns .

Author Comment

ID: 38740075
Ah yes...

Went with:  

    SET [Modified By] = SYSTEM_USER

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


Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

920 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