Can I return UNIQUEIDENTIFIER from a stored procedure using the RETURN statement or is it only by using the OUTPUT statement?
i.e to return the PersonID UNIQUEIDENTIFIER:
CREATE PROCEDURE CreatePerson
@Name NVARCHAR(255),
@Desc TEXT
AS
DECLARE @Count INT
DECLARE @JobFileGUID UNIQUEIDENTIFIER
-- Check if job exists?
SET @Count = (SELECT COUNT(Name) AS Name FROM Person WHERE Name=@Name)
IF @Count < 1
BEGIN
SET @PersonGUID = NEWID();
INSERT INTO Person
(PersonID, Name, [Desc])
VALUES (@PersonGUID, @Name, @Desc)
END
SELECT @PersonGUID = Person.PersonID
FROM Person
WHERE Name = @Name
RETURN @PersonGUID
GO
Thanks