<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>mssql Archives - Creative People | Quality IT services</title>
	<atom:link href="https://creativepeople.gr/tag/mssql/feed/" rel="self" type="application/rss+xml" />
	<link>https://creativepeople.gr/tag/mssql/</link>
	<description>Quality IT Services</description>
	<lastBuildDate>Mon, 11 Nov 2019 09:27:14 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://creativepeople.gr/wp-content/uploads/2020/02/fav.png</url>
	<title>mssql Archives - Creative People | Quality IT services</title>
	<link>https://creativepeople.gr/tag/mssql/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Msg 8152, Level 16, State 10 String or binary data would be truncated. The statement has been terminated.</title>
		<link>https://creativepeople.gr/everyday-it-issues/msg-8152-level-16-state-10-string-or-binary-data-would-be-truncated-the-statement-has-been-terminated/</link>
		
		<dc:creator><![CDATA[Chrysostomos Psaroudakis]]></dc:creator>
		<pubDate>Tue, 14 Feb 2017 13:54:56 +0000</pubDate>
				<category><![CDATA[Everyday IT issues]]></category>
		<category><![CDATA[MS Access]]></category>
		<category><![CDATA[Sql]]></category>
		<category><![CDATA[microsoft sql]]></category>
		<category><![CDATA[mssql]]></category>
		<guid isPermaLink="false">https://cpltditdays.wordpress.com/?p=589</guid>

					<description><![CDATA[<p>It appears that when you want to &#8220;insert into&#8221; data from an nvarchar(max) field to another nvarchar(max) field, and the table has a lot of data<span class="excerpt-hellip"> […]</span></p>
<p>The post <a href="https://creativepeople.gr/everyday-it-issues/msg-8152-level-16-state-10-string-or-binary-data-would-be-truncated-the-statement-has-been-terminated/">Msg 8152, Level 16, State 10 String or binary data would be truncated. The statement has been terminated.</a> appeared first on <a href="https://creativepeople.gr">Creative People | Quality IT services</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>It appears that when you want to &#8220;insert into&#8221; data from an nvarchar(max) field to another nvarchar(max) field, and the table has a lot of data the ms sql query is terminated giving you the error</p>
<p><i>Msg 8152, Level 16, State 10 String or binary data would be truncated The statement has been terminated.</i></p>
<p>After narrowing down data fields and understanding which field is the problematic one, and given that the source field is nvarchar(max) and so is the destination, you need to go on troubleshooting this.</p>
<p>Suppose I have the following query:</p>
<p>INSERT INTO ServiceJournal</p>
<p>(PriorityID, TechnicianID, ServiceTaskID, ClientID, ServiceDate, ProblemReportDateTime, EventTypeid, ReminderID, CustomerSiteID, DetailedProblemDescription)</p>
<p>SELECT        3 AS Expr1, Customers.EmployeeResponsibleID, 16 AS Expr2, Customers.CustomerID, GETDATE() AS Expr3, GETDATE() AS Expr4, 2 AS Expr5, 2 AS Expr6, 1 AS Expr7, Customer_Tasks.TaskDescription</p>
<p>FROM            Customer_Tasks INNER JOIN</p>
<p>Customers ON Customer_Tasks.CustomerID = Customers.CustomerID</p>
<p>WHERE        (Customer_Tasks.IsMaintenance = 1)</p>
<p>The field DetailedProblemDescription is the one producing the problem.</p>
<p>I tried creating a new field on the destination table ServiceJournal, called test as nvarchar(max) and changed my query to</p>
<p>INSERT INTO ServiceJournal</p>
<p>(PriorityID, TechnicianID, ServiceTaskID, ClientID, ServiceDate, ProblemReportDateTime, EventTypeid, ReminderID, CustomerSiteID, test)</p>
<p>SELECT        3 AS Expr1, Customers.EmployeeResponsibleID, 16 AS Expr2, Customers.CustomerID, GETDATE() AS Expr3, GETDATE() AS Expr4, 2 AS Expr5, 2 AS Expr6, 1 AS Expr7, Customer_Tasks.TaskDescription</p>
<p>FROM            Customer_Tasks INNER JOIN</p>
<p>Customers ON Customer_Tasks.CustomerID = Customers.CustomerID</p>
<p>WHERE        (Customer_Tasks.IsMaintenance = 1)</p>
<p>The script inserts a number of rows, as it should!</p>
<p>I tried to rename the problematic field to DetailedProblemDescription2 and retry. It does not work.</p>
<p>I backed up the field data to another field and deleted the field. This is where I started losing the table integrity. I had to take the data with an export script, drop and recreate the table (taken from a backup) and restore the data.</p>
<p>Need to mention that concatenating the DetailedProblemDescription field with cast (DetailedProblemDescription as nvarchar(4000)) or other data type, did not work as well.</p>
<p>To make a long story short, I overcame the insert into problem by putting</p>
<p>SET ANSI_WARNINGS  OFF;</p>
<p>&nbsp;</p>
<p>SET ANSI_WARNINGS  ON;</p>
<p>As long as the &#8220;problematic&#8221; field characters don&#8217;t go over 4000 characters, no problem occurs. I will need to test it with more in the next months.</p>
<p>Have no time to investigate this further, but worth&#8217;s writing it down and sharing:)</p>
<p>Till next time!</p>
<p>The post <a href="https://creativepeople.gr/everyday-it-issues/msg-8152-level-16-state-10-string-or-binary-data-would-be-truncated-the-statement-has-been-terminated/">Msg 8152, Level 16, State 10 String or binary data would be truncated. The statement has been terminated.</a> appeared first on <a href="https://creativepeople.gr">Creative People | Quality IT services</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
