Is there any specific sql query to covert clob data to string? - database

One of the column is having clob data in DB and I want to validate whether a particular text is present in that clob data but i am not able to achieve it through sql query, as the formats differs . Is there any specific sql query to covert clob data to string?

Related

Exporting a VARCHAR(MAX) Field from SQL to Excel in SSIS

I'm creating a SSIS Package to export Data from a SQL Server Table into an Excel Sheet. My Table has one column of datatype VARCHAR(MAX). And this column can have data as big as 30,000 characters sometimes. So I used a Data Conversion block to convert that column's DataType from it's original datatype text stream [DT_TEXT] to Unicode text stream [DT_NTEXT]. But when I execute the Package, I get this error An error occurred while setting up a binding for the "MyColumnName" column. The binding status was "DT_NTEXT".
I googled a lot but I couldn't get an answer to my problem. I'd appreciate all the help that I could get.
You can skip the data conversion task and just force the type when you extract from SQL Server SELECT CAST(MyBigColumn AS nvarchar(max)) As MyBigColumnUnicode but you're going to run into the problem that a cell in Excel cannot hold 100k characters.
Total number of characters that a cell can contain: 32,776
Excel specifications and limits

SSIS Datatype Conversion issue

I have build a SSIS Package with FlatfileImport(csv)---DataConversion---Lookup Transformation---OLDDBDestination. This package has erros between DataConversion and SearchTransformation.
After the csv import I try to convert a csv field into decimal because in the DB the field has the format decimal but when I make a connection in the Look up Transformation from csv table to db table, I get an error with datatype is different.
Any idea what the problem is?
Make sure that the SSIS data types of both columns used in the lookup match. The data type resulting from the decimal conversion should be DT_NUMERIC, which corresponds to the SQL Server decimal data type as stated in the mapping chart of the documentation. To verify that the data type of the input column used in the mapping to match in the lookup is also DT_NUMERIC right-click the Lookup and select Show Advanced Editor. After this go to the Input and Output Properties tab, then the Lookup Input node, expand the Input Columns folder below that and highlight the column used in the lookup. The Common Properties window on the right will show the data type. If this is not DT_NUMERIC change the lookup to use a SQL query instead and cast this column as a decimal (SQL Server) data type with a SQL command, then verify that it is now DT_NUMERIC in the Advanced Editor. I'm assuming the Lookup is to a SQL Server database, if not see the other columns in the data mapping chart of the SSIS reference above. You will also want to ensure that the scale and precision is the same for both columns used in the Lookup, which can be viewed on the Advanced editor of the Lookup as well. For the Data Conversion Task, this can be found either on the regular editor or Advanced Editor by going to Input and Output Properties > Data Conversion Output > Output Columns > then select the converted column.

Hashkey(MD5) generation for JSON data (ntext)column SQL server

We have to generate a hashkey column in a table for incremental load, where it has multiple JSON data (Ntext)columns with more than 40,000 characters and it varies.
Currently we are converting it to varchar and generating, but varchar has limitation. Could you please suggest?

Chinese Character is not displaying correctly

I am using openrowset to import data from sql server to another sql server. One of the column data is a chinese character. When i successfully import to my sql server, the column data which is chinese character show weird sign on my table. The data type for the column from the external is varchar where the data type for the column from my side is nvarchar.
Is there any way i can do so that the data can be display properly?
P.S. The weird character show is °»´ú³q¹DÂ_½u

How do I save xml exactly as is to a xml database field?

At the moment, if I save <element></element> to a SQL Server 2008 database in a field of type xml, it converts it to <element/>.
How can I preserve the xml empty text as is when saving?
In case this is a gotcha, I am utilising Linq to Sql as my ORM to communicate to the database in order to save it.
What you're asking for is not possible.
SQL Server stores data in xml columns as a binary representation, so any extraneous formatting is discarded, as you found out.
To preserve the formatting, you would have to store the content in a text field of type varchar(MAX) or nvarchar(MAX). Hopefully you don't have to run XML-based queries on the data.
http://msdn.microsoft.com/en-us/library/ms189887.aspx

Resources