SQLServerCentral.com / SQL Server 2012 / SQL Server 2012 - T-SQL / Best options for this scenarion / Latest PostsInstantForum.NET v99.99.99SQLServerCentral.comhttp://www.sqlservercentral.com/Forums/notifications@sqlservercentral.comFri, 09 Dec 2016 06:49:48 GMT20RE: Best options for this scenarionhttp://www.sqlservercentral.com/Forums/Topic1521984-3077-1.aspxYessir. Spacklesville. Population: me.Maybe I'll take up whittling.Wed, 11 Dec 2013 19:31:40 GMTsqldriverRE: Best options for this scenarionhttp://www.sqlservercentral.com/Forums/Topic1521984-3077-1.aspx[quote][b]erikd (12/11/2013)[/b][hr]That was the link in my Spacklesville comment in my first post :-)[/quote]Ah! So it was! Sounds like your community. :-PWed, 11 Dec 2013 19:10:58 GMTdwain.cRE: Best options for this scenarionhttp://www.sqlservercentral.com/Forums/Topic1521984-3077-1.aspxThat was the link in my Spacklesville comment in my first post :-)Wed, 11 Dec 2013 19:05:44 GMTsqldriverRE: Best options for this scenarionhttp://www.sqlservercentral.com/Forums/Topic1521984-3077-1.aspxI also did something interesting in this article, where I used DelimitedSplit8K to format a dynamic SQL string into lines, butit only works with strings that are up to 8000 in length. However if you had a splitter that operated on NVARCHAR(MAX) you could use the same technique, the benefit of which is that it displays line numbers along with the Dynamic SQL that conform to the error messages.[url=http://www.sqlservercentral.com/Authors/Articles/Dwain_Camps/1444841/]How to Design, Build and Test a Dynamic Search Stored Procedure [/url]Wed, 11 Dec 2013 19:05:09 GMTdwain.cRE: Best options for this scenarionhttp://www.sqlservercentral.com/Forums/Topic1521984-3077-1.aspxMaybe you need to take a look at this (by Jeff Moden):[url=http://www.sqlservercentral.com/articles/T-SQL/72129/]Display More Than 8000 Characters [/url]Wed, 11 Dec 2013 19:01:50 GMTdwain.cRE: Best options for this scenarionhttp://www.sqlservercentral.com/Forums/Topic1521984-3077-1.aspxHi Dwain,In my tinkering with it, it certainly seemed like the error messages I'd get would match where the print statements stopped printing. So, if the error was something like "incorrect syntax near FROM", the print statement would cut short some of the table name. I'm currently using varchar(max) so it does print as much as possible for debugging. I'll try nvarchar(max) out and see if it executes. All this EAV nonsense is making me want to learn Java or something. Sheesh. :angry:Thanks!Wed, 11 Dec 2013 18:51:34 GMTsqldriverRE: Best options for this scenarionhttp://www.sqlservercentral.com/Forums/Topic1521984-3077-1.aspxI'm not sure I understand the problem. The allowed @SQL string is NVARCHAR(MAX) (as you defined in the post you linked to). So why would 7000+7500 characters be too much for it?Granted it won't display the entire thing if you try to PRINT it, but that won't stop it executing.Wed, 11 Dec 2013 18:14:23 GMTdwain.cBest options for this scenarionhttp://www.sqlservercentral.com/Forums/Topic1521984-3077-1.aspxHi,I have two dynamic pivot tables that I need to join. The problem I'm running into is that at execution, one is ~7500 characters and the other is ~7000 characters. I can't set them both up as CTEs and query, the statement gets truncated. I can't use a temp table because those get dropped when the query finishes. I can't use a real table because the insert statement gets truncated.Do I have any other good options, or am I in [url=http://www.sqlservercentral.com/articles/T-SQL/72129/]Spacklesville[/url]?For reference, [url=http://www.sqlservercentral.com/Forums/Topic1486814-3077-3.aspx#bm1519413]this is what I'm doing[/url].Thanks!Wed, 11 Dec 2013 10:47:51 GMTsqldriver