Running a batch file to update a field with strange character in SQL Server DB

I have a table called Field in my SQL Server database. The table has a field called "Units".

I have a batch script which inserts a lot of things into here using OSQL and one of the things entered is the pound sign (£). When OSQL runs the queries, it converts the £ sign to -ú instead.

What I need to have is a separate batch file which updates all this at the end

e.g.

update field set units = '£' where units = '-ú'

This sql above works fine if I run in a query but through OSQL it doesn't work.

I have found that editing the file in DOS mode in TextPad allows me to put in the DOS symbol for £ and that bit works ok, but I don't know how to replace the -ú part so I can do the replacement.

Any ideas?

13.10.2009 14:57:21
3 ОТВЕТА

I believe that what you need to do is pass the ASCII value of the character, using chr(XX), where XX is the ASCII value for '-ú'

0
13.10.2009 15:02:24
РЕШЕНИЕ

Got it

update field set units = 'œ' WHERE units = '-£'

I took the character from my database, pasted it into the file which was in DOS mode then saved. I then opened this file up in TextPad and it came up as -£

Worked fine

Thanks

1
13.10.2009 15:03:51

have OSQL run a stored procedure:

CREATE PROCEDURE FixIt
AS

update field set units = '£' where units = '-ú'

GO
0
13.10.2009 15:16:56