July 21, 2003 at 8:00 am
I have added a column to a table (Userid) and am trying to capture the user id of the user inserting a row. Can someone please remind me how to do this?
I thought that selecting system_user and updating the new column like this:
update table
set column = system_user
where INSERTED.pk_id = table.pk_id
However i get an error saying:
The column prefix 'INSERTED' does not match with a table name or alias name used in the query.
TIA
July 21, 2003 at 8:05 am
Are you doing this in a trigger? INSERTED is not available outside a trigger.
Joseph
July 21, 2003 at 8:16 am
Hi Carl,
quote:
I have added a column to a table (Userid) and am trying to capture the user id of the user inserting a row. Can someone please remind me how to do this?I thought that selecting system_user and updating the new column like this:
update table
set column = system_user
where INSERTED.pk_id = table.pk_id
However i get an error saying:
The column prefix 'INSERTED' does not match with a table name or alias name used in the query.
speaking of an update trigger?
SELECT
...
FROM inserted ins
for capturing the system user you can use SUSER_SNAME() as default value on your table.
Cheers,
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
July 21, 2003 at 11:59 am
Table Inserted and Deleted are only available
with trigger. IF u want to get info of user add recored u can add a column like username and put default (SUSER_SNAME) for that column .
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply