Transact SQL :: Read Unicode Character Using OPENROWSET

Jun 27, 2012

I am reading text file using OPENROWSET command. The read is successful. But the UNICODE characters in the file is not showing properly in the output.I am using a sql like below:

select
*
FROM
OPENROWSET('MICROSOFT.ACE.OLEDB.12.0','Text;Database=ppa20-igloo-fsMODELSTORECR106_GIM_UKGISourceFilesProcess;HDR=Yes;Format=Delimited(|)',
'SELECT * FROM [RUW_P_Reinsurers_Aviva_and_Others_Map.txt]')

how should I read the unicode characters correctly.

View 8 Replies


ADVERTISEMENT

OPENROWSET, Unicode And Encoding Scheme

Nov 14, 2007



I have an automated system, which keeps on collecting data and put them in a datafile with data delimited by tabs. This datafile will be sent to OPENROWSET and data gets inserted into the database. Recently I observed a situation in which a character(é) gets inserted as two characters(é) adn that is creating lot of problems. I was able to observe, the character é in UTF-8 gets changed to é in UTF-7 format.
This strange situation comes while inserted data into an nvarchar field. In the format(.fmt) file, which will be sent as one of the arguments to OPENROWSET, this field is specified as "SQLCHAR" datatype with collation SQL_Latin1_General_CP1_CI_AS.

My questions are,

1) In which codeset OPENROWSET reads the datafile? Is there any way to specify to OPENROWSET to read in a specific format(i.e. as Unicode data or non-unicode data etc.)?
2) Can we specify datatype as "SQLCHAR" and collation type as "SQL_Latin1_General_CP1_CI_AS", in format file, for unicode characters? If this is wrong,what is the alternate for Unicode characters?
3) Is there any other place the problem can be?

Thanks in advance.

View 1 Replies View Related

Read Chinese Character From SQL(SQL Server 2005) Database Table Column And Display Chinese Character

Feb 1, 2008

Hi!

I have a table like this below and it doesn't only contain English Names but it also contain Chinese Name.
CREATE TABLE Names
(FirstName NVARCHAR (50),
LastName NVARCHAR (50));
I tried to view the column using SQL Query Analyzer, It didn't display Chinese Character.
I know that SQL Server 2005 is using UCS-2 Encoding and Chinese Character uses Double Byte Character Set (DBCS) Encoding.
I want to read the FirstName and LastName columns and display in Window Form Data Grid and ASP.NET Grid View.
I tried to use this code below and it didn't work. It convert some of the English Name to Chinese Character and it display the chinese character and some still in the original unreadable characters.
Does anybody know how to read those character from SQL Table and display the correct Chinese Character without converting the English Name into Chinese also?
Thanks

int codePage = 950;
StringBuilder message = new StringBuilder();
Encoding targetEncoding = Encoding.GetEncoding(codePage);
byte[] encodedChars= targetEncoding.GetBytes(str);
.
message.AppendLine("Byte representation of '" + str + "' in Code Page '" + codePage + "':");
for (int i = 0; i < encodedChars.Length; i++)
{
message.Append("Byte " + i + ": " + encodedChars);
}

message.AppendLine(" RESULT : " + System.Text.Encoding.Unicode.GetString(encodedChars));
Console.Writeline(message.ToString());

View 1 Replies View Related

Unicode Character Data Types && Collation

Dec 18, 2006

Hi there,Trying to work with SQL2005 with Hebrew characters. If i use the Unicode character data types do i need to change the database collation???. regards   

View 5 Replies View Related

Character Set,Sort Order & Unicode Collation

Nov 7, 2000

Hi Everybody,

Can anyone tell me apart from "sp_helpsort" system stored procedure, is there any other command to find details of Character Set,Sort Order & Unicode Collation?.

thanks,
Vasu

View 2 Replies View Related

Usinf OPENROWSET To Read From A .ttx File

Mar 5, 2008


I have a .ttx file similar to this:

"xxxxxxxxx" "dc8" "184:30" "168:00" "00:00" "00:00" "00:00" "00:00" "00:00" "00:00" "00:00" "00:00" "00:00" "00:00" "00:00" 0 0 0 1

I want to read from this file from T-SQL, I saw in a previous post that its possible to do it using OPENROWSET (http://msdn2.microsoft.com/en-us/library/ms190312.aspx)

I don€™t have a clue what parameters i must use on the OPENROWSET T-sql command (provider name to ttx ?)

I would appreciate if anyone could give an example of how to do this

Thanks !

View 7 Replies View Related

How To Read CSV File In SQL Server 2005 Using OpenRowSet Function

May 4, 2007

Hi

i want to access a CSV file using OpenRowSet function in SQL Server 2005.



Anyone having any idea; would be of great help.

Regards,

Salman Shehbaz.

View 8 Replies View Related

DB Engine :: Read Unicode Data From Server 2008

Oct 18, 2015

way to read data from database already stored as question marks .that because by mistake i insert the data "arabic" from  the VS as sqltext but the field in the database is nvarchar now i want to get the data back.

View 4 Replies View Related

SQL 2012 :: OPENROWSET To Read In Data From Excel 2010 File (XLSX)

Jun 12, 2015

I have a test server (TEST1) running SQL 2012 and Windows 2012R2. One of the developers wants to use OPENROWSET to read in data from an Excel 2010 file (an xlsx file).

I have loaded the Microsoft Drivers in "AccessDatabaseEngine_64.exe" and enabled the Ad Hoc Distributed Queries option in SQL.

This is the sample code we are working with:

SELECT
X.MEMBID
FROM OPENROWSET(
'MSDASQL',
'Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=etworkserverFolder1Folder2MEMBIDs.xlsx',
'SELECT * FROM [Sheet1$]'
) AS X

I can run the sample query from my laptop with SSMS (I have admin rights) and I can also run it as SA from my laptop. So all is good, right?

But if I RDC into TEST1, I cannot run the query. I get this error:

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Excel Driver] Your network access was interrupted. To continue, close the database, and then open it again.".
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Excel Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x574 Thread 0xb74 DBC 0x1d07f08 Excel'.".
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Excel Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x574 Thread 0xb74 DBC 0x1d07f08 Excel'.".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".But wait! It gets better.

I can run the query as SA from TEST1.

And of course, the developer can't run it either.

And it works fine in the production server.

I'm thinking the basics are there but something isn't right in some permission somewhere.

View 9 Replies View Related

Transact SQL :: Making Server Database Read / Write From Read Only

Jan 12, 2012

i attached adventure works in sql server 2008 and it showing as read only ,make it read write or remove read only tag from database.

View 11 Replies View Related

Transact SQL :: Should Unicode Types Be Used For New Projects?

May 20, 2015

Should Unicode types, like nvarchar, be used when creating new databases that are used by new applications?

View 11 Replies View Related

Transact SQL :: Get Everything After And Before Certain Character In Server

Sep 29, 2015

I have a database column that stored the weblinks like the one below :

[URL] .....

I want to extract string  "airfare" which comes  after string "cname= " and before the  string "&ccontent" .This is actually the value for cname. The entire string size can be of variable length. 

View 3 Replies View Related

Transact SQL :: How To Get All Characters Before Special Character

Jul 21, 2015

I would like to know how can i only get the characters before the special character?

For example if the mail id is The.Champ123@gmail.com i need to extract The.Champ123 and if the mail id is TheChamp@gmail.com I need to get TheChamp.So basically i would like to get the characters from the string before '@' character.

View 14 Replies View Related

Transact SQL :: Invalid Character Validation

Jun 3, 2015

if the variable contains any of the character  that is not present in the  following Below table then it should display "InValid Character" else "valid Character"

DECLARE @MyString VARCHAR(100)
SET @MyString = 'ABC$['
select 
case 

[code]....

View 3 Replies View Related

Transact SQL :: Inserting Character At The Beginning And End Of A Field

Sep 17, 2015

How to modify values in a SQL Database. In the table PRDDEmpmaster there is a field called email_address, and for those fields that have a value I need to change that value to add { } opening/closing "curly braces" to that field. 

For example,

RPARSONS@YAHOO.COM becomes
{RPARSONS@YAHOO.COM} .  Nulls/empty fields remain as is.    

View 6 Replies View Related

Transact SQL :: Extracting Certain Text After Special Character

May 18, 2015

I would like to write a SQL to extract a text after certain _ special character.Example : Relationship_Person_Type_Aunt

View 9 Replies View Related

Integration Services :: CDC Source Transformation And Converting Non-Unicode To Unicode String SSIS

May 6, 2015

In my package , I am used CDC Source transformation and received the Net changes then insert into Destination. But whatever Data coming from CDC source data type Varchar value needs to Converting Non Unicode string to Unicode string SSIS. So used Data conversion transformation to achieved this.  I need to achieve this without data conversion.

View 3 Replies View Related

Integration Services :: Column A Cannot Convert Between Unicode And Non-unicode String Data Types

Aug 7, 2012

I am following the SSIS overview video- URL...I have a flat file that i want to import the contents onto a SQL database.I created a Dataflow task, source file and oledb destination.I am getting the folliwung error -"column "A" cannot convert between unicode and non-unicode string data types".in the origin file the data type is coming as string[DT_STR] and in the destination object it is coming as "Unicode string [DT_WSTR]"I used a data conversion object in between, dosent works very well

View 5 Replies View Related

Excel Destination Error: Columnxx Cannot Convert Between Unicode And Non-unicode String Data Types

Jul 28, 2005

Good afternoon

View 32 Replies View Related

Problem Saving/retrieving Unicode Characters NVARCHAR With Unicode Collation (java Jdbc)

Aug 8, 2006

I'm connecting to a SQL Server 2005 database using the latest (beta) sql server driver (Microsoft SQL Server 2005 JDBC Driver 1.1 CTP June 2006) from within Java (Rational Application Developer).

The table in SQL Server database has collation Latin1_General_CI_AS and one of the columns is a NVARCHAR with collation Indic_General_90_CI_AS. This should be a Unicode only collation. However when storing for instance the following String:




‚¬_£_ÙÚÜÛùúüû_ÅÆØåæøߣÇçÑñ_¼½¾_ЎўЄєÒ?Ò‘_прÑ?туф_ЂЉЊЋ
... it is saved with ? for all unicode characters as follows (when looking in the database):
‚¬_£_ÙÚÜÛùúüû_ÅÆØåæøߣÇçÑñ_¼½¾_??????_??????_????





The above is not correct, since all unicode characters should still be visible. When inserting the same string directly into the sql server database (without using Java) the result is ok.

Also when trying to retrieve the results again it complains about the following error within Java:





Codepage 0 is not supported by the Java environment.




Hopefully somebody has an answer for this problem. When I alter the collation of the NVARCHAR column to be Latin1_General_CI_AS as well, the data can be stored and retrieved however then of course the unicode specific characters are lost and results into ? So in that case the output is as described above (ie ‚¬_£_ÙÚÜÛùúüû_ÅÆØåæøߣÇçÑñ_¼½¾_??????_??????_????)

We would like to be able to persist and retrieve unicode characters in a SQL Server database using the correct JDBC Driver. We achieved this result already with an Oracle UTF8 database. But we need to be compliant with a SQL Server database as well. Please help.

Thanks in advance for your help.

View 7 Replies View Related

SQL 2012 :: (SSIS) - Cannot Convert Between Unicode And Non-unicode Data Types

Sep 9, 2015

I have an SSIS package that pulls data from a MYSQL DB (Using RSSBus for Salesforce in SSIS to accomplish this). Most of the columns are loading properly, but I have many columns that I need to convert.

I have been using the Data Conversion dataflow task in SSIS to convert the rows.

I have 2 data conversions that work on most of the columns, but the DESCRIPTION column continues to return an error saying "Cannot convert between unicode and non-unicode types", regardless of what I choose on the Data Conversion task. So, basically I want to dump this column data into a SQL table with NVARCHAR datatypes. Here is what I am doing in my SSIS package...

1) Grab subset of data from SOURCE
2) Converts to TEXTSTREAM. (Data Conversion)
3) Converts to STRING. (Data Conversion)
4) Load Destination table. (OLE DB Destination)

I have also tried to simply convert the values to STRING, but that doesn't work either.

So, I have 2 Data Conversions working here that process most of the data correctly. What I can do to load the DESCRIPTION column?

View 8 Replies View Related

SSIS: Unicode And Non-unicode String Data Types

May 14, 2008

Hi guys and gals,

I've had some great headaches with SSIS this morning, which I have managed to get a workarounds for, but I'm not happy with them so I've come to ask for advice.

Basically, I am exporting data from an SQL Server database into an Excel spreadsheet and hitting issues with unicode and non-unicode data types.

For example, I have a column that is char(6) and have added a data conversion step to the data flow, which converts it to type DT_WSTR and then everything works!

However, this seems like a completely un-neccessary step as I should be able to do the conversion in T-SQL - but no matter what I try I keep getting the same problem.

SELECT Cast(employee_number As nvarchar(255)) As [employee_number]
FROM employee
WHERE forename = 'george'

ErrorValidation error. details: 1 [1123]: Column "employee_number" cannot convert between unicode and non-unicode string data types.

I know I have a solution (read: workaround) but I really don't want to do this everytime!

Any suggestions for what else to try?

View 8 Replies View Related

Cannot Convert Between Unicode And Non-unicode String Data Types.

Apr 6, 2006

I have an Excel Source component hooked to an OLE DB Destination component in my SSIS 2005 Data Flow Task.  After I mapped the excel columns to the OLE DB table columns i get these errors below.  I noticed that for the first error, the Excel Field format (when you mouse over the column name in the mappings section in OLE DB component) is of type [DTWSTR] and the corresponding SQL field from my SQL table that it's mapping to is of type [DT_STR] when mousing over that field in the mappings in the properties of my OLE DB component.  All table fields in SQL Server for the table I'm inserting into are of type varchar.

print screens here:

http://www.webfound.net/excel_ssis.jpg

http://www.webfound.net/excel_to_oledb_mappings.jpg

Package Validation Error

------------------------------
ADDITIONAL INFORMATION:

Error at Data Flow Task [OLE DB Destination [27]]: Columns "Commission Agency" and "CommissionAgency" cannot convert between unicode and non-unicode string data types.

Error at Data Flow Task [OLE DB Destination [27]]: Column "Product" cannot convert between unicode and non-unicode string data types.

Error at Data Flow Task [OLE DB Destination [27]]: Columns "Officer Code" and "OfficerCode" cannot convert between unicode and non-unicode string data types.

Error at Data Flow Task [OLE DB Destination [27]]: Columns "Agency Name" and "AgencyName" cannot convert between unicode and non-unicode string data types.

Error at Data Flow Task [OLE DB Destination [27]]: Columns "Agency Id" and "AgencyID" cannot convert between unicode and non-unicode string data types.

Error at Data Flow Task [OLE DB Destination [27]]: Columns "Tran Code" and "TranCode" cannot convert between unicode and non-unicode string data types.

Error at Data Flow Task [OLE DB Destination [27]]: Columns "User Id" and "UserID" cannot convert between unicode and non-unicode string data types.

Error at Data Flow Task [OLE DB Destination [27]]: Columns "Acct Number" and "AccountNumber" cannot convert between unicode and non-unicode string data types.

Error at Data Flow Task [DTS.Pipeline]: "component "OLE DB Destination" (27)" failed validation and returned validation status "VS_ISBROKEN".

Error at Data Flow Task [DTS.Pipeline]: One or more component failed validation.

Error at Data Flow Task: There were errors during task validation.

 (Microsoft.DataTransformationServices.VsIntegration)

 

View 3 Replies View Related

Cannot Convert Between Unicode And Non-unicode String Data Type

Jan 15, 2007

HI.

I'm having this problem.

I use Visual Studio's, integration project to load XML file into SQL Server. In the XML file, i have defined collumns as string. When i try to load XML file with parts defined in scheme as string, i get an error "cannot convert between unicode and non-unicode string data type.

Destinated collumns in SQL are defined as varchar and char.



Thanks for help

View 11 Replies View Related

Integration Services :: Cannot Convert From Unicode To Non-unicode Error

May 7, 2009

For packages that I have created to read Oracle 10g tables, that work fine with debugging in 32-bit mode, I get an error message on all string fields when I try to run in 64-bit mode.  An example error message is:[OLE DB Source [1]] Error: Column "ACCT_UNIT" cannot convert between unicode and non-unicode string data types.Another interesting warning included is:[OLE DB Source [1]] Warning: The external columns for component "OLE DB Source" (1) are out of synchronization with the data source columns. The external column "ACCT_UNIT" needs to be updated.I cannot even try to convert this data with a Data Conversion item because the (red) error is on the OLE DB Source item and stops there.  It doesn't matter what the destination is or even if there is a destination in the package yet.I'm using Oracle Provider for OLE DB, Oracle Client version 10.203 for 32-bit and Oracle Client 10.204 for 64-bit.Oracle is 10g on a UNIX 64-bit server and the data is not unicode.I'm using SQL Server Enterprise 2008 (10.0.1600) on Windows Server 2008 Standard SP1 on a 64-bit server.The packages work fine in 32-bit mode and the data is not unicode data.  When I change Run64BitRuntime to True in the Debugging Property Page, I get the error on the OLE DB Source item.  I also get the error when I schedule a package to run using the SQL Server Agent.

View 4 Replies View Related

Cannot Convert Between Unicode And Non-unicode String Data Types

Mar 7, 2008

Hi,

I have spent countless number of hours trying to solve the issue, but to no vail. My problem is SSIS throws "cannot convert between unicode and non-unicode string data types" when i am try to transform data from DB2 to SQL Server 2005. And please note, i tried all possibilities like changing the destination field which is in SQL Server 2005 to nvarchar and also text. But so far no help. And i also looked at previous posts which did not help me either.

Thank You in advance.

View 8 Replies View Related

Transact SQL :: Remove Read Only From A Database?

Aug 26, 2011

i have a data base sql Server .I wrote a stored procedure or attach my database but it is attached in read only mode how can remove read-only.

this is my stored procedure.

create procedure attache
as
declare @trouvemdf int
declare @trouveldf int
if exists (select name from sysdatabases where name='Gestion_Parc')

[Code] ....

i try this EXEC sp_dboption 'Gestion_Parc', 'read only', 'FALSE' but it causes those error

Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "C: Gestion_Parc.mdf". Operating system error 5: "5 (Access is denied.)".
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "C: Gestion_Parc_log.ldf". Operating system error 5: "5 (Access is denied.)".
Msg 945, Level 14, State 2, Line 1

[Code] ....

View 3 Replies View Related

MS SQL Server - Transfer Database From Non-unicode To Unicode

Jun 29, 2006

Any one know the process of transfering the database from non-unicode to unicode. Coz I like to transfer the data from english to hebrew.

View 1 Replies View Related

Transact SQL :: Blank Element In XML Not Read By XQuery

May 14, 2015

declare @inputXml xml
set @inputXml='<root>
  <row>
    <col>start_date</col>
    <col>1</col>
    <col>rpton#on#13-May-2015|$|rpton#on#13-May-2015</col>

[Code] ...

I get below output ....

But I need below output ....

View 7 Replies View Related

Transact SQL :: Error - Conversion Failed When Converting Date And / Or Time From Character String

Nov 16, 2015

I've imported a CSV file into a table in SQL Server 2012. It's a large file, 140,000+ rows, so I couldn't covert it to Excel first to preserve the date format due to Excel's row limit. In the CSV file, there were 3 column with date data in "31-Aug-09" format, and the import automatically transformed these in "31AUG09" format (varchar(50)) in SQL Server.  Now I need to convert these 3 columns from varchar to datetime so I could work with them in date format.

I've tried several things,e.g,

select
convert(datetime,
right(admdate,4)+left(admdate,2)+substring(admdate,3,3))

or

select
convert(datetime,
substring(admdate,6,4)+substring(admdate,1,2)+substring(admdate,3,3))

but keep getting the same error message (Msg 241) "Conversion failed when converting date and/or time from character string".

View 4 Replies View Related

Transact SQL :: Read Data From CSV Files And Insert Into DataBase

May 6, 2015

I have a requirement to

a. Read data from Different CSV files.
b. insert and update data to Data base in multiple table using joins.

This execution runs for 1-2 hours.I can use C# with Ado.net, but only concern I see is if in between execution fails due to some connection or other error. All insert data has to be cleaned up again.I feel writing and Store procedure inside transaction, which will take path's for CSV file as input and insert data in database. using transaction we will have flexibility rollback to original state.

View 9 Replies View Related

Transact SQL :: Read All DB Objects In Dependency And Need Object Definition

Jun 16, 2015

I need a solution (script) where I can pull all objects(DB's incudes tables, views, synonyms, stored procedures, primary key, foreign key, triggers etc) definitions from the server in a dependency order. I want to generate a script from these objects, where if I run script all objects should be created the way it is..

.All dependencies should be automatically available in script in a dependency order.  What is the best way to bring all objects (definition) in form of scripts.

These are the fields am looking - databsename, schemaname, objectname, typeofobject, depenedencyorder (nothing but level)...

View 6 Replies View Related

Non-Unicode To Unicode Data Conversion

Jul 23, 2005

Hi all, we are now planning to upgrade our application from anon-unicode version to a unicode version. The application's backend isa SQL Server 2000 SP3.The concern is, existing business data are stored using collation"Chinese_PRC_CI_AS", i.e. Simplified Chinese. So I thought we need toextract these data out to the new SQL Server which is using Unicode (Iassume it means converting them to nchar, nvarchar type of fields for Idon't enough information from the application side, or is there ageneral unicode collation that will make even char and varchar types tostore data as Unicode?).The problem is what's the best and most efficient way to do this dataconversion?bcp? DTS? or others?thanks a lot

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved