检查临时函数的约束 table
Check Constraint with function on temporary table
我试图在临时 table 上使用函数设置检查约束并收到以下错误:
Msg 4121, Level 16, State 1, Line 10
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.CheckCustomers", or the name is ambiguous.
...但是 select dbo.CheckCustomers()
有效。
通常可以对温度设置这样的约束吗table?
请记住,临时 table 实际上是在系统数据库 tempDB 中创建的,而不是在您的实际数据库中创建的。因此,为了能够在临时 table 中将函数用作检查约束,该函数必须存在于 tempDB 中。
但是,一件重要的事情是每次重新启动服务器时都会重新创建 tempDB。因此,如果您确实想采用这种方法,则需要围绕它进行设计。 (参考文献Inside Microsoft SQL Server 2008 T-SQL Programming)
我试图在临时 table 上使用函数设置检查约束并收到以下错误:
Msg 4121, Level 16, State 1, Line 10
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.CheckCustomers", or the name is ambiguous.
...但是 select dbo.CheckCustomers()
有效。
通常可以对温度设置这样的约束吗table?
请记住,临时 table 实际上是在系统数据库 tempDB 中创建的,而不是在您的实际数据库中创建的。因此,为了能够在临时 table 中将函数用作检查约束,该函数必须存在于 tempDB 中。
但是,一件重要的事情是每次重新启动服务器时都会重新创建 tempDB。因此,如果您确实想采用这种方法,则需要围绕它进行设计。 (参考文献Inside Microsoft SQL Server 2008 T-SQL Programming)