In SQL Server 2008 (TSQL), I\'ve created a stored procedure like this:
CREATE PROCEDURE SP_1_10_2
AS
declare @mostValuableBook nvarchar(255)
SELECT @mostValu
You can also create a function to return the value you desire instead of relying on numeric return codes. SQL Functions come in quite handy. See example below which returns the last name with the highest client id using the LIKE operator
Use MYDB
GO
CREATE Function fn_LastClientIdByName
(
@nameLike NVARCHAR(10)
)
RETURNS NVARCHAR(100)
AS
BEGIN
DECLARE @result nvarchar(100)
DECLARE @clientName NVARCHAR(100)
SELECT top 1 @clientName = [clientLast] + ' ' + [clientFirst]
FROM [dbo].[duiClientOnly]
WHERE clientLast like @nameLike + '%'
order by clid desc
select @result = @clientName
return @result
END