Troubleshooting
Error 2731
Severity Level 16
Message Text
Column '%.*ls' has invalid width: %d.
Explanation
This error occurs when a user is attempting to create a view in which a column is empty, or has a length that is less than or equal to 0. This is not allowed in Microsoft® SQL Server™ 2000.
An example of a query which generates this error follows. Note that the data for CategoryName is 0-length.
CREATE VIEW myview AS
SELECT CategoryName = '', p.ProductName, c.Description
FROM Products p, Categories c
WHERE p.CategoryId = c.CategoryId
AND p.UnitsInStock > 0
GO
Action
You can resolve this error by:
- Not using zero-length columns when creating a view.
- Specifying a default value for column length. For example:
create view myview as char(10) "empty column"