﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / String Max Length / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 05:05:18 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: String Max Length</title><link>http://www.sqlservercentral.com/Forums/Topic679253-391-1.aspx</link><description>Thank you man!:-P</description><pubDate>Thu, 19 Mar 2009 20:33:15 GMT</pubDate><dc:creator>Simon Su</dc:creator></item><item><title>RE: String Max Length</title><link>http://www.sqlservercentral.com/Forums/Topic679253-391-1.aspx</link><description>[quote]An error is appearI found the max length of the @ssql is 4000.[/quote]Hi,     The issue is, eventhough you have set the @ssql variable as varchar(8000), it will take only 4000 characters. And the error you are getting is because of the dynamic query what you are constructing is having more than 4000 characters. Hence, I suggest you to use NVarchar(max) for @ssql variable. Hope this will solve the issue.Regards,Ashok S</description><pubDate>Thu, 19 Mar 2009 05:02:52 GMT</pubDate><dc:creator>Ashok.S</dc:creator></item><item><title>RE: String Max Length</title><link>http://www.sqlservercentral.com/Forums/Topic679253-391-1.aspx</link><description>sys.objects.name is NVARCHAR[code]SELECT @ssql = @ssql + 'Drop procedure ' + CAST(name AS VARCHAR(128)) + ' '[/code]</description><pubDate>Thu, 19 Mar 2009 04:19:07 GMT</pubDate><dc:creator>Mark-101232</dc:creator></item><item><title>String Max Length</title><link>http://www.sqlservercentral.com/Forums/Topic679253-391-1.aspx</link><description>I want to delete all the stored procedure I created in the database. I write the following statements:DECLARE    @ssql varchar(8000)SET           @ssql = ''SELECT      @ssql = @ssql + 'Drop procedure ' + name + ' 'FROM        sys.objects WHERE      type = 'p'SELECT LEN(@ssql)EXECUTE ( @ssql )An error is appearI found the max length of the @ssql is 4000.Thanks</description><pubDate>Thu, 19 Mar 2009 03:48:45 GMT</pubDate><dc:creator>Simon Su</dc:creator></item></channel></rss>