I'm fairly new to SQL. I'm trying to write a stored procedure that will check if the 'alias' is in the table, and if so return the details; if it doesn't exist it will add it. At the moment I've got it 50% working but it won't return the alias details if it does exist
DECLARE @Alias VARCHAR(MAX)
IF NOT EXISTS(SELECT * FROM [Users] where [Alias] = @Alias)
INSERT INTO [Users] ([Alias], [Country], [Role])
VALUES (@Alias, 'UK', 'User')
Can anyone tell me where I'm going wrong?
Thanks in advance
Tom