Avatar of Merion
Merion
Flag for United States of America asked on

ISNULL is truncating my verchar(max) field

I have a 2 sub query  in the my isnull() function.
subquery1 = varchar(100)
subquery2 = varchar(max)

select
isnull (subquery1,subquery2) as test
from table1
join table2 on table1.id = table2.field2
where table1.x = table2.y

the problem is my subquery2 is getting truncated when i get the result..

any help will be greatly appreciated.

 
Microsoft SQL Server

Avatar of undefined
Last Comment
Merion

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Guy Hengel [angelIII / a3]

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
sampipes

try isnull(CAST(subquery1 AS varchar(MAX), subquery2)
aibusinesssolutions

It looks like it is assigning varchar(100) to "test", and if it's null it keeps the varchar(100), so the answer would be to set both subqueries to varchar(max).
aibusinesssolutions

Dang, gotta be fast around here.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Merion

ASKER
Thanks a lot. I was struggling with it form past 2 hours.....