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 @mostValuableBook = Name
FROM books
WHERE price =
( SELECT MAX(price)
FROM books
WHERE izd LIKE '%BHV%' );
return @mostValuableBook
GO
But, when I'm trying to execute it:
declare @x nvarchar(255)
EXECUTE @x = SP_1_10_2;
SELECT 'The most expensive BHV book:', @x AS 'Name'
GO
I'm getting an error:
Conversion failed when converting the nvarchar value 'Internet Explorer 3 original' to data type int.
It seems like the problem is in the line
EXECUTE @x = SP_1_10_2;
Can you please tell me what's wrong? Why is it trying to convert to int?