I created a stored procedure that gets a person's name, matches the name with values in a table and return the correct format via output variable. If the name is not in the table/database the stored procedure simply output the original entry. This part works fine.

Now I want to do both first and last names together in the same stored procedure; example:

1. If first name has a match, output matched - *output variable*
2. If Last name has a match send out a match - *output variable*
3. If both names match send out the match for both BUT via different output variable.

I am having a hard time because I am not sure how to process both names, and get both or one, or the other:

I could do separate Procedures but that would not be wise.

***Table Name Is: (StringFormat)***

![enter image description here](https://i.stack.imgur.com/E9YOx.png)

***Stored Procedure:***

```
CREATE PROCEDURE [dbo].[uspFormat]

@FName VARCHAR(30),
@FNameMatchedValue VARCHAR(30) OUTPUT

AS 
BEGIN

SET NOCOUNT ON

DECLARE @ValueMatched VARCHAR(30)

SELECT @ValueMatched =  StringValue
FROM StringFormat WHERE MatchedValue = @FName;

IF @ValueMatched IS NOT NULL

BEGIN
SET
@FNameMatchedValue = @ValueMatched
END

RETURN 0

END

```

Thanks for looking:

***UPDATE: Please Review My Solution:***

Okay after posting I went back and modified the code which I had done wrong before:
It is working but returning unique values even when one name is a match. However I am not sure this is the best way to do it:

Another Change: I simply used two viriables to get the matched rather then one:

`@FirstNameMatched` and `@LastNameMatched`

***Code after modification:***

```
CREATE PROCEDURE [dbo].[uspFormat]

@FName VARCHAR(30),
@LName VARCHAR(30),
@FNameMatchedValue VARCHAR(30) OUTPUT,
@LNameMatchedValue VARCHAR(30) OUTPUT

AS 
BEGIN

SET NOCOUNT ON

DECLARE @FirstNameMatched VARCHAR(30)
DECLARE @LastNameMatched VARCHAR(30)

SELECT @FirstNameMatched =  StringValue
FROM StringFormat WHERE MatchedValue = @FName;

IF @FirstNameMatched IS NOT NULL

BEGIN
SET
@FNameMatchedValue = @FirstNameMatched
END

ELSE
BEGIN
SET @FNameMatchedValue = @FName
END

BEGIN 
SELECT @LastNameMatched =  StringValue
FROM StringFormat WHERE MatchedValue = @LName;

IF @LastNameMatched IS NOT NULL

BEGIN
SET
@LNameMatchedValue = @LastNameMatched
END

ELSE
BEGIN
SET @LNameMatchedValue = @LName
END
END

RETURN 0

END

```