我有创建的定义的表类型
CREATE TYPE dbo.MyTableType AS TABLE ( Name varchar(10) NOT NULL, ValueDate date NOT NULL, TenorSize smallint NOT NULL, TenorUnit char(1) NOT NULL, Rate float NOT NULL PRIMARY KEY (Name, ValueDate, TenorSize, TenorUnit) );
我想创建这种类型的表。从这个答案的建议是尝试
CREATE TABLE dbo.MyNewTable AS dbo.MyTableType
在我的SQL Server Express 2012中产生了以下错误消息:
关键字“ OF”附近的语法不正确。
SQL Server Express不支持此功能吗?如果是这样,我可以用其他方式创建它,例如使用DECLARE吗?
DECLARE
–Create table variable from type. DECLARE @Table AS dbo.MyTableType
--Create new permanent/physical table by selecting into from the temp table. SELECT * INTO dbo.NewTable FROM @Table WHERE 1 = 2 --Verify table exists and review structure. SELECT * FROM dbo.NewTable