BrunoLM
BrunoLM

Reputation: 100351

CHAR function on SQL Server is returning different values on different servers

When I do

SELECT CHAR(193)

On my local database it returns Á, but when I do the same on a database running on another server it returns .

I expect Á as the correct value, how can I fix the function?

The databases were created individually, they aren't exactly the same.

Upvotes: 2

Views: 814

Answers (2)

Thomas
Thomas

Reputation: 64645

Try using NChar instead of Char:

SELECT NCHAR(193)

Upvotes: 4

SQLMenace
SQLMenace

Reputation: 135021

The collation is not the same, run this to see that you get different answers

SELECT CHAR(193) collate SQL_Latin1_General_Cp1256_CI_AS  
SELECT CHAR(193)
SELECT CHAR(193) Latin1_General_CI_AS

to find out the collation for the database run this

Select DATABASEPROPERTYEX(DB_name(),'Collation')

Upvotes: 1

Related Questions