The %S_MSG that starts with '%.*ls' is too long.

Error Message:
Msg 103, Level 15, State 4, Line 1
The %S_MSG that starts with ‘%.*ls’ is too long. Maximum length is %d.

Severity level:
15.

Description:
This error message appears when you try to use an identifier name that exceeds the maximum allowed length.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Errors of the Severity Level 15 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. You must choose a short name with up to 128 characters.

Versions:
All versions of SQL Server.

Example(s):
USE tempDB
IF OBJECT_ID(‘t’) IS NOT NULL
 DROP TABLE t
GO
DECLARE @sql nvarchar(MAX)
DECLARE @myCol nvarchar(200)
SET @myCol = REPLICATE(‘a’, 200)
SET @sql = ‘CREATE TABLE t(‘ + @myCol + ‘ int)’
EXEC sp_ExecuteSQL @sql

Remarks:
In the above example we try to name a column with an identifier which is 200 characters long. Because this exceeds the maximum allowed length, the error is raised.

]]>

Leave a comment

Your email address will not be published.