Hello, While working with stored procedures I came across something I didn't know how to handle.
I wanted to make a stored procedure where, One could give it 2 parameters. With these two parameters, it would return the uniqueidentifier of the row that matched, or if no match was found it would create one.
I get stuck at the first part.
ALTER PROCEDURE [dbo].[GetOrCreateAlbumID] @BandID uniqueidentifier, @AlbumName varchar(50), @AlbumID uniqueidentifier OUTPUT AS BEGIN DECLARE @tempid uniqueidentifier SET @tempid = SELECT AlbumID From Album WHERE Album.AlbumName = @AlbumName AND Album.BandID = @bandID IF(@tempid != NULL) BEGIN SET @AlbumID = @tempid RETURN 0 END ELSE BEGIN --Add the new row RETURN 0 END END
Thanks for the help,