SQL SERVER – Fix: Error Msg 128 The name is not permitted in this context. Only constants, expressions, or variables allowed her
Reference:http://blog.sqlauthority.com/2007/03/22/sql-server-fix-error-msg-128-the-name-is-not-permitted-in-this-context-only-constants-expressions-or-variables-allowed-here-column-names-are-not-permitted/
Error Message:
Server: Msg 128, Level 15, State 1, Line 3
The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
Causes:
This error occurs when using a column as the DEFAULT value of another column when a table is created.CREATE TABLE [dbo].[Items] (
[OrderCount] INT,
[ProductAmount] INT,
[TotalAmount] DEFAULT ([OrderCount] + [ProductAmount])
)
Executing this CREATE TABLE statement will generate the following error message:
Server: Msg 128, Level 15, State 1, Line 5
The name ‘TotalAmount’ is not permitted in this context.
Only constants, expressions, or variables allowed here.
Column names are not permitted.
Solution/Workaround/Fix:
When setting the DEFAULT value of a column make sure to use only constants, expressions or variables and not another column.
System functions can be used as DEFAULT values. e.g. GETDATE(), NEWID()
Use Computed Column in place of Default keyword.CREATE TABLE [dbo].[Items] (
[OrderCount] INT,
[ProductAmount] INT,
[TotalAmount] AS ([OrderCount] + [ProductAmount])
)
相關文章
- SQL Error (1130): Host IP is not allowed to connect to this MySQL serverErrorMySqlServer
- 報錯-only final is permittedMIT
- SQL SERVER Msg 7391解決方法SQLServer
- error C2713: Only one form of exception handling permitted per functionErrorORMExceptionMITFunction
- Using Multiple Variables with the Same Name
- SQL SERVER Msg 7357錯誤解決SQLServer
- NFS mount results in "vmount: operation not permitted" errorNFSMITError
- SQL*Plus Substitution VariablesSQL
- Name [spring.liveBeansView.mbeanDomain] is not bound in this Context. Unable to findSpringBeanViewAIContext
- error: '[class name]' does not name a typeError
- ERROR FIX:- rpmdb: unable to join the environmentError
- Microsoft SQL Server, Error: 15128 ()ROSSQLServerError
- MongoDB:"errmsg" : "DBClientBase::findN: transport error:MongoDBclientError
- How to fix Rosetta stone error 2123 -- "This was an error in the application"ROSErrorAPP
- error :does not name a typeError
- 小程式 · 報錯:Error: errCode: -501007 ,errMsg: Invalid Key Name (__keyPath)Error
- MSSQL Server Rename Server_nameSQLServer
- error: 'cout' does not name a type|Error
- php中出現Strict Standards: Only variables should be passed by reference in的解決方法PHP
- Host 'localhost' is not allowed to connect to this MySQL serverlocalhostMySqlServer
- nginx server_nameNginxServer
- To fix sql server 2008 r2 Evaluation period has expired by change the keySQLServer
- Shared Server Architecture (128)Server
- Error: User gpmon is not allowed to login Command CenterError
- MIGO error:"Goods receipt for purch. order" is not allowedGoError
- name server cannot be used, reason: Temporary failure in name resolutionServerAI
- sql server 基於fix補丁之incremental servicing model或ISM初識之一SQLServerREM
- Error: User gpmon is not allowed to login Command Center.Error
- Caused by: Error: ' ' is not a valid resource name characterError
- error: ‘xxx’ does not name a typeError
- Error creating bean with name ‘dataSource‘ErrorBean
- error: ‘變數名‘ does not name a type|Error變數
- emulator: ERROR: unknown virtual device nameErrordev
- Oracle:ORA-01219:database not open:queries allowed on fixed tables/views onlyOracleDatabaseView
- In bugfree, 解決Strict Standards: Only variables should be passed by reference in FuncModel.inc.phpPHP
- ERROR: NMO not setuid-root (Unix-only)ErrorUI
- server_name 原始碼分析Server原始碼
- 如何解決 case expressions must be constant expressionsExpress