How do I extend the character limit of a string in management studio The SQL below works to an extend however when I view the output in SSMS tables with a lot of columns appear to be getting cut of in that the string that is generated by the cursor only appears to go to a maximum limit.

    USE [HealthBI]
GO

/*** ENTER VIEW SCHEMA ***/
DECLARE @schema_name AS varchar(MAX) = 'trust'

/*** ENTER CDO TABLE TO REPLICATE ***/
DECLARE @table_name_value  AS varchar(MAX) = 'CDO[_]%'
DECLARE @table_name  AS varchar(MAX)
DECLARE @column_name AS varchar(MAX)
DECLARE @viewsql AS varchar(MAX)

DECLARE csr_view CURSOR FOR
SELECT TABLE_NAME ,
STUFF(( SELECT  ',' +QUOTENAME(TABLE_NAME)+'.'+QUOTENAME(COLUMN_NAME)
FROM    INFORMATION_SCHEMA.COLUMNS
WHERE   TABLE_NAME = a.TABLE_NAME
ORDER BY COLUMN_NAME 
FOR XML PATH(''),Type)
    .value('text()[1]','nvarchar(max)' ), 1, 1, '') AS value
FROM    INFORMATION_SCHEMA.COLUMNS a
where  TABLE_SCHEMA = 'dbo'
    AND TABLE_NAME like @table_name_value
    and TABLE_NAME NOT LIKE 'CDO_CDS%'
GROUP BY a.TABLE_NAME

    OPEN csr_view
        FETCH NEXT FROM csr_View INTO @TABLE_NAME, @column_name
    SET @viewsql = ''
--  PRINT @TABLE_NAME PRINT @column_name

        WHILE @@fetch_status = 0
        BEGIN

        IF OBJECT_ID('['+ @schema_name + '].[' + @table_name + ']') IS NULL
        SET @viewsql = @viewsql + '
        CREATE '
        ELSE
        SET @viewsql = @viewsql + '
        ALTER '

        SET @viewsql = @viewsql + 'VIEW [' + @schema_name + '].[' + @table_name + ']
        AS SELECT ' + @column_name + '
        FROM [dbo].[' + @table_name + ']'


        IF @schema_name = 'trust' AND @table_name &lt;&gt; 'CDO_MPI'
        SET @viewsql = @viewsql + '
        INNER JOIN [CDO_MPI]
        ON [CDO_MPI].[UNIQUE_ID] = [' + @table_name + '].[CDO_MPI_UNIQUE_ID]
        AND [CDO_MPI].[IS_DUMMY_PATIENT] = ''N''   GO'

        IF @schema_name = 'trust' AND @table_name = 'CDO_MPI'
        SET @viewsql = @viewsql + '
        WHERE [CDO_MPI].[IS_DUMMY_PATIENT] = ''N'''
        PRINT (@viewsql)
--       EXEC (@viewsql)

        FETCH NEXT FROM csr_View INTO @TABLE_NAME, @column_name
        SET @viewsql = ''

        END
    CLOSE csr_view
DEALLOCATE csr_View
change  PRINT (@viewsql) to  SELECT (@viewsql)