Can you please check again. Yuor query is not checking for any of the MAX types. Try this one instead:
SELECT t.name AS
,
c.name AS [column],
c.system_type_id,
typ.name AS [type],
c.max_length,
fg.name AS [filegroup]
FROM sys.columns c
JOIN sys.types typ ON c.system_type_id = typ.user_type_id
JOIN sys.tables t ON c.object_id = t.object_id
JOIN sys.data_spaces ds ON t.lob_data_space_id = ds.data_space_id
JOIN sys.filegroups fg ON ds.data_space_id = fg.data_space_id
WHERE fg.name LIKE 'Primary%'
AND (
(
-- nvarchar, varbinary, varchar
typ.system_type_id IN (231, 165, 167)
-- (MAX)
AND c.max_length = -1
)
-- text, image, xml, ntext
OR typ.system_type_id IN (35, 34, 241, 99)
)
ORDER BY t.name,
fg.name;
As an aside, views like sysobjects have been maintained in the product since SQL 2005, but only for backward compatibility with code written for SQL 2000 and before. Please start using the current catalog views instead: Mapping System Tables to System Views (SQL Server 2008 R2)
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato