我的代码很简单:
SqlCommand command = new SqlCommand("CREATE TABLE [dbo].[ClientData]([ClientDataID] [int] IDENTITY(1,1) NOT NULL,[SessionID] [char](24) NOT NULL,[Browser] [varchar](20) NOT NULL,[IP] [varchar](20) NOT NULL,[OperatingSystem] [varchar](30) NOT NULL,CONSTRAINT [PK_SessionData] PRIMARY KEY CLUSTERED([ClientDataID] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ON [PRIMARY]");
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
command.Connection = connection;
command.ExecuteNonQuery();
}
执行后,我收到此错误:
关键字“ON”附近的语法不正确
该查询由 MS SQL 2008 生成,我只是照原样复制它。有人可以告诉我为什么这不起作用吗?
谢谢。