help with SQL Nvarchar

1

Hello,

I had some problems with a code in SELECT ...

example:

SELECT dados FROM banco WHERE CPF='$CPF' // com o código assim estava dando alguns erros pois o bd era em SQL e o Servidor windows.

The solution was:

SELECT CAST(CAST([dados] AS VARCHAR(8000)) AS TEXT) AS dados FROM dbo.banco WHERE CPF='$CPF;

I wanted to know if you have a simpler solution that does not need such extensive code ...

Type, if I want to drill down the fields of the table and use 4 fields, it only works if I put the CAST where it is nVARCHAR . Note: I can not change in the nVARCHAR bank to only VARCHAR .

Thank you in advance!

    
asked by anonymous 12.01.2015 / 17:36

1 answer

1

At the end of the day the solution was in the php.ini file, but why?

When doing $query = mssql_query("SELECT SEXO, NOME, RG...) WHERE... it was an error because the use of the MSSQL parameter was turned off in the file "php.ini", browsing the file I found the following line mssql.compatability_mode = Off changed to On , then solved, I needed to use CAST only in some fields nVarChar(max) that therefore gave error.

I think it's just that and I hope to help someone who is in the same situation.

    
16.01.2015 / 17:29