![]() |
|
|
By: Jugal Shah | Read Comments (1) | Print Jugal has 8+ years of extensive SQL Server experience and has worked on SQL Server 2000, 2005, 2008 and 2008 R2. Related Tips: More |
|
Problem
The OSQL utility uses ODBC to communicate with SQL Server. The user’s problem is that the ODBC driver he is using to connect to the database is performing translations on the character data in the T-SQL script. Extended characters, which are not in the standard ASCII character set, are translated by the driver based on drive settings. The character translation option is ON by default when SQL Server executes scripts through the OSQL utility.
Solution
We can resolve this issue by configuring DNS or T-SQL . To resolve this issue we will take the below example.
Steps to reproduce the issue
Step 1 Create an Example table by using the below code.create table Example
(
id int identity(1,1),
extendedCharactervalue varchar(1000)
);
insert into Example(extendedCharactervalue) values('Rrotégé Company, LLC')
|
Step 2 Save below INSERT query into text file/SQL file. I have named the file Query.txt
insert into Example(extendedCharactervalue) values('Rrotégé Company, LLC')
|
Step 3 Execute the below OSQL statement from command prompt


Solution - I Insert Extended character using DNS with OSQL
Step 1 Create ODBC System DSN. Go to Control Panel -- Administrative Tool -- SELECT Data Sources (ODBC)




Step 1.6 Select the database name from list and click on Next button






Solution - II Using T-SQL
-- ascii function retuns the ascii value of extended character
select ascii('é')
-- char function converts the ascii value to character
select char(233)
insert into Example(extendedCharactervalue)
select 'Rrot' + char(233) + 'g' + char(233) + ' Company, LLC' |
Next Steps
| Share: | Share | Tweet |
|
![]() |
![]() |
Connect with MSSQLTips.com |
| Friday, April 09, 2010 - 6:01:54 AM - urcuterajendra | Read The Tip |
|
Hey Jugal, I have also checked your this post, it is working absolutely fine. Thanks Raj |
|
|
privacy | disclaimer | copyright | advertise | about authors | contribute | feedback | giveaways | user groups Some names and products listed are the registered trademarks of their respective owners. Edgewood Solutions LLC | MSSharePointTips.com | MSSQLTips.com |