title: SQL Server: Return uniqueidentifier from stored procedure
body: <p>Can I return UNIQUEIDENTIFIER from a stored procedure using the RETURN statement or is it only by using the OUTPUT statement?</p>
  
  <p>i.e to return the PersonID UNIQUEIDENTIFIER:</p>
  
  <pre><code>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 &lt; 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
  </code></pre>
  
  <p>Thanks</p>