I'm backing up all of my views by running this query, and storing the results in a table:
select
TABLE_CATALOG as DBName
, TABLE_NAME as ViewName
, VIEW_DEFINITION as ViewDef
, datalength(VIEW_DEFINITION) as [Length]
, GETDATE() as ImportDate
from INFORMATION_SCHEMA.VIEWS
order by DBName, ViewName
But the datatype for the VIEW_DEFINITION column is set to nvarchar(4000) and some of my views are much longer than that - so they're truncating.
Columns in INFORMATION_SCHEMA.VIEWS
Can I change the datatype of the VIEW_DEFINITION column to varchar(max) somehow?