VBAPrincess
Programmer
I am a newbie to SQL syntax and triggers. I have a website someone else developed where the users have a username that is the same as their password. These two values get set when the user registers for the site. I would prefer the user have the ability later to update their email and have the username update as well.
To add confusion to this, there were users who were added prior to launch who already had some usernames that were not email addresses. Those we can keep so my trigger should only update usernames IF the username is an email address WHEN the email address is updated.
Here's my original trigger:
How do I modify this trigger so that the user's username is only updated if the username is an email address? I'd like to test if the username has the "@" symbol because all of the non-email address usernames will definitely not have that character.
TIA for any help!
Diana
VBA Princess
-- I'm hoping to grow up to be a Goddess!
To add confusion to this, there were users who were added prior to launch who already had some usernames that were not email addresses. Those we can keep so my trigger should only update usernames IF the username is an email address WHEN the email address is updated.
Here's my original trigger:
Code:
CREATE TRIGGER [dbo].[update_users_username]
ON [dbo].[User]
FOR UPDATE
AS
BEGIN
SET NOCOUNT ON;
-- Insert statements for trigger here
IF (UPDATE(Email))
BEGIN
UPDATE [User] SET [USER].USERNAME = [USER].Email
END
END
GO
How do I modify this trigger so that the user's username is only updated if the username is an email address? I'd like to test if the username has the "@" symbol because all of the non-email address usernames will definitely not have that character.
TIA for any help!
Diana
VBA Princess
-- I'm hoping to grow up to be a Goddess!