Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
RichJ
Contributor III
Contributor III

NCLOB to VARChar

Hi Sir,

We have a replica from MS SQL Server to Snowflake with numerous transform: NCLOB to Varchar.  Datatype in Source db is NVARCHAR (max) hence NCLOB in Qlik, but client in Snowflake uses different lengths for Varchar, e.g., a target table has one column Varchar(1000) and the other column Varchar(5000).  How can we achieve that in Qlik replication since Qlik doesn't support table Transform for NCLOB?

Thanks,

Richard 

Labels (4)
1 Solution

Accepted Solutions
shashi_holla
Support
Support

@RichJ 

Yes, you can have table level transformations, can modify the column data type from NCLOB to STRING(1000) or WSTRING(1000) as required.

If you prefer to have uniform data length on the target then can use Limit LOB size at the task level.

In case you need more details or a working session, please open a support case and we would be happy to help.

 

View solution in original post

11 Replies
Dana_Baldwin
Support
Support

Hi @RichJ 

You can set "Limit LOB size" at the task or table level so the data will fit in the target column:

Dana_Baldwin_0-1712856056486.png

 

RichJ
Contributor III
Contributor III
Author

Thanks for reply.   As I said,  there is a target table which has different varchar lengths, (say) Varchar(1000) and Varchar(5000).  What "Limit LOB size" should be used in that case? 

Furthermore, "Limit LOB size" cannot be used in table level for Snowflake in Azure.

RichJ
Contributor III
Contributor III
Author

If Qlik can treat it on the source EP as WSTRING(1000) or WSTRING(5000), things will work out as WSTRING can have table level transformation.

john_wang
Support
Support

Hello @RichJ ,

Besides @Dana_Baldwin comment, yes , we can retrieve different length LOBs easily if the source table has PK or Unique Index.

Let's use source_lookup  & substring function for every LOB column. For example in the first column we truncate the VARCHAR(max) to 1000 chars only:

 

source_lookup('NO_CACHING','dbo','testclob','substring(notes,1,1000)','id=?',$id)

 

where 'dbo' is the schema name, 'testclob' is the table name, 'notes' is CLOB column, 'id' is the table PK. IN above expression we retrieve the first 1000 chars from the VARCHAR(max) column.

If the table has NO PK nor Unique Index then then we can do that by defining a VIEW which get the desired length LOBs.

I hope it solve the issue.

Regards,

John.

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up!
shashi_holla
Support
Support

@RichJ 

Yes, you can have table level transformations, can modify the column data type from NCLOB to STRING(1000) or WSTRING(1000) as required.

If you prefer to have uniform data length on the target then can use Limit LOB size at the task level.

In case you need more details or a working session, please open a support case and we would be happy to help.

 

RichJ
Contributor III
Contributor III
Author

Thanks for  reply.

One can change it to STRING(1000) or WSTRING(1000), but it does not work - you get the same results. 

The task level Limit LOB Size cannot apply because we have numerous NCLOB's with different Lob size in the task.

shashi_holla
Support
Support

In Snowflake, there is no CLOB or NCOLB data type, it will all be varchar. We can just control the data length. Also, the data length limit can't exceed 16MB.

Mostly Limit LOB size is the preferred approach, if you want it customized then can modify the data length manually in Snowflake.

korsikov
Partner - Specialist III
Partner - Specialist III

Hi All.
I have MS SQL Source and target. DB very Simple 

USE [mysource]
GO
 
/****** Object:  Table [dbo].[t1]    Script Date: 10.11.2025 09:27:14 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
CREATE TABLE [dbo].[t1](
[key_id] [nchar](10) NOT NULL,
[bigdata] [nvarchar](max) NULL,
[smaldata] [nvarchar](50) NULL,
 CONSTRAINT [PK_t1] PRIMARY KEY CLUSTERED 
(
[key_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


But when i try convert [nvarchar](max) aka NCLOB to WSTRING with Global Rules 
Replace column value
	for %.% with column % and data type NCLOB
	to data type WSTRING(4000) and sub type Regular
        Replace target value with: substr($AR_M_SOURCE_COLUMN_DATA, 1, 4000)

It's just conevert column to NVarchar(4000)  and NULL as data. 
How I can solve this issue?

john_wang
Support
Support

Hello @korsikov ,

Please be aware of the following limitation:

Functions such as substr() cannot be applied to LOB fields.
If you need to trim or manipulate these values, you must use source_lookup() instead (as noted in my earlier comment).

Regards,

John.

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up!