JDay2
asked on
Need a stored procedure or trigger for populating removing information
Have following user table
aspnet_users table
UserID
UserName
When I create the user I need this information to auto-populate another table and the same if I delete the user
users table
UserID = aspnet table UserID
Name = aspnet table Username
UserName = aspnet table Username
aspnet_users table
UserID
UserName
When I create the user I need this information to auto-populate another table and the same if I delete the user
users table
UserID = aspnet table UserID
Name = aspnet table Username
UserName = aspnet table Username
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay I have a few questions and I'm going to break them into steps
I had to remove the Action column in your code because don't have that column.
this works for inserting but I need to insert into a name column in the dbo.users table based of Username is this possible?
How do I implement the delete piece based of the UserID?
I had to remove the Action column in your code because don't have that column.
USE []
GO
/****** Object: Trigger [dbo].[trg_insertUsers] Script Date: 3/24/2015 10:08:50 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[trg_insertUsers] ON [dbo].[aspnet_Users] AFTER INSERT
AS
INSERT dbo.Users(UserID, UserName)
SELECT UserID, UserName
FROM Inserted
this works for inserting but I need to insert into a name column in the dbo.users table based of Username is this possible?
How do I implement the delete piece based of the UserID?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Fair enough. I would have been more inclined to use a single TRIGGER, but whatever works for you.
ASKER
The initial post gave me the direction but I didn't have an action column in my table.
The post help understand the concept to formulate the following triggers.
The post help understand the concept to formulate the following triggers.
ASKER