Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

i am facing issue in my below string build query. When i execute query it's print in column heading as ??????. I want column heading in Gujarati with below query (string build query) only.


declare @Query1 varchar(max)

SET @Query1 =' select PersonName as ''નામ'',DateOfBirth as ''જન્મ તારીખ'' from Person where 1=1' 

print (@Query1) 

exec (@Query1)



Results:
???	    ???? ?????
Vinayak	1988-03-09 00:00:00.000
Meet	1990-10-05 00:00:00.000
Jitesh	1990-12-31 00:00:00.000
Yatin	1986-03-03 00:00:00.000


i want column heading in Gujarati with above query (string building query).

Thanks.

What I have tried:

if i write below simple query and execute than it's work perfect and my column heading display in Gujarati well.

select PersonName as 'નામ',DateOfBirth as 'જન્મ તારીખ' from Person
.


Result:
નામ	        જન્મ તારીખ
Vinayak	    1988-03-09 00:00:00.000
Meet	    1990-10-05 00:00:00.000
Jitesh	    1990-12-31 00:00:00.000
Yatin	    1986-03-03 00:00:00.000
Posted
Updated 26-Jul-20 0:50am

1 solution

Stop using VARCHAR, and use NVARCHAR instead.
VARCHAR is basically 8 bit ASCII text, NVARCHAR is 16 bit Unicode:
SQL
DECLARE @Query1 NVARCHAR(MAX)

SET @Query1 = N'SELECT PersonName AS ''નામ'', DateOfBirth AS ''જન્મ તારીખ'' FROM Person'
And you don't need a WHERE clause if the condition is always true ...
 
Share this answer
 
Comments
Vinayak V Joshi 26-Jul-20 7:00am    
Hi OriginalGriff,

Thanks buddy. It's perfect solution and work for me. Yes i need where but here i put 1=1.

Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900