I need to return Russian text from a SQL Server 2005 database table.
In the following example which is a simple way of describing my dilemma, the @Test variable will print out question marks:
DECLARE @Test nvarchar(max)
SET @Test = 'Баннер'
PRINT @Test
(Note that the @Test value is Russian text, for those who don’t have the font installed.)
But if I change the code to the following, the @Test variable will print out the text as intended:
DECLARE @Test nvarchar(max)
SET @Test = N'Баннер'
PRINT @Test
Here is what I want to know:
In my real-world example I am doing the following with a stored proc:
EXEC usp_GetContent @Content = @Test
The value for @Test is in Russian, but gets displayed as question marks. If the proc looked like this, the Russian comes through fine:
EXEC usp_GetContent @Content = N'Баннер'
But this is not a possibility for me; I need to pass in a variable.
Any advice?
Thanks.
As long as the stored procedure parameter is defined as unicode such as nvarchar, and the calling code explicitly defines the parameter object of the command with the same type it should work fine.
When you have written it in SQL you have passed in a varchar in your first example, so it has not understood it.
The issue is the line:
Not the stored procedure.