How to user prefix 'N' for unicode with nvarchar variable in SQL Server? For example:
Given this variable:
declare @Query1 nvarchar(max)
I can assign to it like this:
set @Query1 = N'لاحظات'
But what if I want to use N@Query1
somewhere?
You only need to use N'xyz' when you have literal text. Once the nvarchar data is in a variable or result set column of nvarchar data type you no longer need to use the N'...' notation, the system knows the data type at that point.
try it out:
DECLARE @A nvarchar(100)
,@B nvarchar(100)
SET @A = N'anything here!!'
SET @B=@A --would work the same if coming from a query result set as well
SELECT @B --will show special unicode characters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With