I´m trying to create a MSSQL tabel where after a UserRegistation (create user wizard) the UserID from "aspnet_Users (dbo)" will be copied into this new tabel. Can anyone tell me how to do this?
Thanks
I´m trying to create a MSSQL tabel where after a UserRegistation (create user wizard) the UserID from "aspnet_Users (dbo)" will be copied into this new tabel. Can anyone tell me how to do this?
Thanks
If you want an automated system that responds on specific actions, a TRIGGER
is what you're most likely looking for.
In your case, it sounds as if you want to respond to INSERT
s happening on the dbo.aspnet_Users table. The code would be something similar to this (pseudo-code, not tested):
CREATE TRIGGER trgNewUser ON dbo.aspnet_Users
AFTER INSERT
AS
INSERT INTO myTable (userID)
SELECT userID FROM INSERTED
INSERTED
is a special logical table that essentially has the same structure as the table the trigger is created on, and it will contain the latest row INSERT
ed into the table. Thus, you can use that to capture newly added records, and have the trigger take appropriate actions.
More info on Triggers: