osql query to text file pound sign (£) encoding problem

  • Hi,

    I have a frustrating problem whereby I am using a Select statement to output to a (new) text file, but my currency symbol (UK Pounds - "£") is being in someway encoded and comes out as "œ".

    I am actually taking a field (varchar) from the database that has a "£" in the data and the SQL below mimics the actual code :

    SET @cmdTxt ='osql -s (local) -d DATABASE -U USERNAME -P PASSWORD -Q "SELECT ''£'' FROM ##tempEmail " -o ' + @MessageFile + ' -w7000 -h-1'

    EXEC master..xp_cmdshell @cmdTxt

    I have tried CHAR(163) and get the same result. I've tried N''£'' and also get the same output.

    Any ideas?

  • "SELECT ''£'' FROM ##tempEmail "

    i think the problem is with select statement

    try with

    select '''£''' from......

    so three ' before and after £

    ----------
    Ashish

  • Thanks for the reply - but the select statement is fine and was only provided as an illustration - i have taken my longer convoluted statement and depersonalised it (possibly with too many/few apostrophes).

    The actual select is "select FIELDNAME from table" - the point I was trying to make is that even if I do a literal SELECT ''£'' FROM #faketable the encoding issue still occurs.

    My select statement works fine - a text file is created, but the encoding (or something) is wrong.

  • Will, why not try BCP for pulling data into a text file ?? using that you can control the NCHAR or VCHAR character sets...

  • Thanks - I will look into that for sure (I am not very familier with BCP - i am not a DBA just an underpaid developer) 🙁

    I was (still am) hoping for a char value or something to make it nice and simple for me!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply