Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Varchar(Max) field cutting off data after 8000 characters SQL Server 2008

$
0
0

Hi,

We have a scenario on which we are preparing the SQL query dynamically by string concatenat and then at the end EXECUTING the query using EXECUTE statement but observed that the VARCHAR(MAX) data type is not storing more then 8000 character.

Here is the code snip.How i am using and where the variable is not storing more them 8000 character

We have a table "tblUserAssignedResourcesData" where we are storing "FilterType" and "FiletrValue" and then preparing the string like this:


DECLARE @sqlQuery_UR VARCHAR(MAX)   
SET @sqlQuery_UR=''

DECLARE @agentsColumns_UR VARCHAR(MAX)             
SELECT @agentsColumns_UR = ISNULL(@agentsColumns_UR,'') +''''+ FilterValue + ''''+',' FROM @tblUserAssignedResourcesData Where FilterType = 1             
SELECT @agentsColumns_UR = LEFT(@agentsColumns_UR,LEN(@agentsColumns_UR)-1)             
SET @sqlQuery_UR=@sqlQuery_UR+'[UserAgent] in('+ @agentsColumns_UR +')'

--Upto this all the Agents are storing properly then adding mobility user

DECLARE @mobilityColumns_UR VARCHAR(MAX)            
SELECT @mobilityColumns_UR = ISNULL(@mobilityColumns_UR,'') +''''+ FilterValue + ''''+',' FROM @tblUserAssignedResourcesData Where FilterType = 3               
SELECT @mobilityColumns_UR = LEFT(@mobilityColumns_UR,LEN(@mobilityColumns_UR)-1)

SET @sqlQuery_UR=@sqlQuery_UR +' or '+'[MobilExtensionID] in('+@mobilityColumns_UR+')' 


print '@sqlQuery_UR ->' + @sqlQuery_UR

--Print statement should print all the Agents and Mobility values but it is not printing and hence my SQL query is faling to execute


Anyhelp will be appriciable

Thanks,
Bijay


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>