Why This Error Happens
Error 6622 occurs because SQL Server 2025 has continued the deprecation path for legacy Large Object (LOB) data types, and text, ntext, and image are now fully blocked in specific operations such as full-text indexing, computed columns, or certain system functions. This typically surfaces when an older database (migrated via backup/restore or detach/attach) still contains schema definitions using these deprecated types, which modern SQL Server 2025 operations refuse to process. Essentially, the engine is enforcing strict type-checking rules that reject legacy types in contexts where only varchar(max), nvarchar(max), or varbinary(max) are now permitted.
Step-by-Step Resolution Guide
Step 1: Identify the Offending Column and Object
- Run the following query to locate columns still using deprecated types:
SELECT t.name AS TableName, c.name AS ColumnName, ty.name AS DataType
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
JOIN sys.types ty ON c.user_type_id = ty.user_type_id
WHERE ty.name IN ('text', 'ntext', 'image');
- Note the schema name, table name, and column name returned — this is almost always the root cause of Error 6622.
Step 2: Alter the Column to a Modern Data Type
- Back up the database first using SQL Server Management Studio (SSMS) 21 or
BACKUP DATABASE [YourDB] TO DISK = 'C:\Backups\YourDB.bak'; - Run an
ALTER TABLEstatement to convert the column:
ALTER TABLE dbo.YourTable
ALTER COLUMN YourColumn NVARCHAR(MAX);
- If the column is part of a full-text index, drop the full-text index first via
DROP FULLTEXT INDEX ON dbo.YourTable;before altering, then recreate it afterward.
Step 3: Check Linked Views, Stored Procedures, and Functions
- Search dependent objects using:
SELECT DISTINCT o.name, o.type_desc
FROM sys.sql_modules m
JOIN sys.objects o ON m.object_id = o.object_id
WHERE m.definition LIKE '%text%' OR m.definition LIKE '%ntext%' OR m.definition LIKE '%image%';
- Update any
CAST,CONVERT, or variable declarations inside these objects to useVARCHAR(MAX)orNVARCHAR(MAX)instead of the deprecated types.
Step 4: Rebuild Full-Text Catalogs (If Applicable)
- Navigate to SSMS → Object Explorer → [Your Database] → Storage → Full Text Catalogs.
- Right-click the affected catalog and select Rebuild to ensure indexing metadata aligns with the new column data types.
- Confirm via
sys.fulltext_indexesthat the catalog status showsONLINEwith no pending population errors.
Step 5: Restart SQL Server Service and Validate
- Open Services.msc on Windows Server 2025 / Windows 11, locate SQL Server (MSSQLSERVER), and click Restart.
- Alternatively, use PowerShell:
Restart-Service -Name 'MSSQLSERVER' -Force - Re-run the operation that originally triggered Error 6622 to confirm resolution.
Alternative or Verification Steps
- Verify the fix by re-executing the original query, stored procedure, or full-text search operation that previously returned Error 6622 — it should now complete without the “Invalid data type” message.
- If the error persists, check for cached execution plans referencing the old schema using
DBCC FREEPROCCACHE;to force SQL Server to recompile queries against the updated column definitions.