How to fix Error 1790 on Windows Server 2025 / Windows 11

Troubleshooting Guide: Error 1790 – Invalid User-Defined Table Type Name

Why This Error Happens

This error occurs because SQL Server reserves the pound/number (#) sign as a special character to denote temporary tables and temporary stored procedures within the engine’s naming conventions. When the Database Engine parses a CREATE TYPE statement, it checks the first character of the identifier; if it detects a leading #, it throws Error 1790 because user-defined table types are schema-bound, permanent objects and cannot share the temporary object namespace. This is a hard-coded parsing restriction rather than a permissions or configuration issue, meaning it cannot be bypassed via server settings.

Step-by-Step Resolution Guide

Step 1: Identify the Offending T-SQL Script

  • Open SQL Server Management Studio (SSMS) 21 or Azure Data Studio connected to your SQL Server 2025 instance.
  • Locate the CREATE TYPE statement in your script or migration file that is throwing the error.
  • Look specifically for syntax similar to: CREATE TYPE #MyTableType AS TABLE (...).

Step 2: Rename the Table Type Identifier

  • Remove the leading # character from the type name entirely.
  • If the naming convention is required by your organization for clarity, use a valid prefix instead, such as tt_ (table type) or udt_.
  • Update the syntax: CREATE TYPE dbo.tt_MyTableType AS TABLE (ID INT, Name NVARCHAR(50));
  • Ensure you qualify the type with the correct schema (e.g., dbo.) to avoid future ambiguity errors.

Step 3: Update All Dependent References

  • Search your codebase (stored procedures, functions, and application code) for any parameter declarations referencing the old name.
  • Update variable declarations using the old type, such as changing DECLARE @TVP AS #MyTableType to DECLARE @TVP AS dbo.tt_MyTableType.
  • Save the files and re-deploy the updated schema using sqlpackage.exe or your standard CI/CD pipeline if using Infrastructure as Code (IaC).

Step 4: Recompile and Execute the Script

  • Run the corrected CREATE TYPE script against the target database in SSMS.
  • Verify the terminal output confirms “Commands completed successfully” rather than the 1790 error stack.

Alternative or Verification Steps

  • Verification: Query the system view to confirm the object was created correctly by running SELECT name FROM sys.types WHERE is_table_type = 1; and checking that the new name (without the #) appears in the result set.
  • Alternative: If you specifically need the functionality of a temporary structure (rather than a persistent reusable type), do not use CREATE TYPE at all; instead, utilize a standard Temporary Table (e.g., CREATE TABLE #MyTempTable (...)) or a Table Variable (e.g., DECLARE @MyTable TABLE (...)), as these are the correct objects for the # naming convention.