Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>here is update for <a href="https://stackoverflow.com/questions/568734/how-save-sql-stored-prodecures-to-sql-files-via-batch/581111#581111">your</a> batch file (it will work for > 8000 chars limit but it's easy to tune up this limit): </p> <pre><code>for /f %%a in (sp_list.txt) do sqlcmd -E -S SERVER -d DB -h-1 -Q "DECLARE @I INT, @SP1 NVARCHAR(4000), @SP2 NVARCHAR(4000) SET @I = 0 SET @SP1 = '' SET @SP2 = '' SELECT @I = @I + 1, @SP1 = CASE WHEN @I = 1 THEN text ELSE @SP1 END, @SP2 = CASE WHEN @I = 2 THEN text ELSE @SP2 END from dbo.syscomments WHERE id = OBJECT_ID('%%a') SELECT @SP1+@SP2" -o "%%a.sql" </code></pre> <p>personally I'm concerned about so large procedures.</p> <blockquote> <p>that's a limitation, but if you have stored procedures with line numbers longer than 4000 characters, you probably have much, much bigger problems than can be solved reading this blog ... none of my stored procedures have lines greater than about 150 characters long, so that's probably not a huge deal for most people. As I said, if your lines are that long, you have bigger problems!<br> <a href="http://sqlblog.com/blogs/adam_machanic/archive/2006/07/12/reflect-a-tsql-routine.aspx" rel="nofollow noreferrer">Adam Machanic - "Reflect" a TSQL routine</a> </p> </blockquote> <p>but there are also thoughts that large procedures are not an issue:</p> <blockquote> <p>"text" field is defined as NVARCHAR(4000) so each row can only hold up to 4000 characters. However, it is not uncommon to have object code that is much larger than 4000 characters. <a href="http://www.sqlservercentral.com/articles/Stored+Procedure/62975/" rel="nofollow noreferrer">Solomon Rutzky - Searching Objects for Text</a></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload