读书人

关于动态建表的一个有关问题

发布时间: 2012-12-28 10:29:04 作者: rapoo

关于动态建表的一个问题

  Set @CreateSQL='Create Table '+ @TableName + 
'( [OpeningDirection] NCHAR (1) NOT NULL,
CONSTRAINT [CK_'+@TableName+'_OpeningDirection] CHECK ([OpeningDirection]='+'多'+' OR OpeningDirection='+'空'+'))'
Exec(@CreateSQL)


@TableName是传过来的表名,check这个地方总是报错,求指教
[最优解释]
  Set @CreateSQL='Create Table '+ @TableName +  
'( [OpeningDirection] NCHAR (1) NOT NULL,
CONSTRAINT [CK_'+@TableName+'_OpeningDirection] CHECK ([OpeningDirection]='+'''多'''+' OR OpeningDirection='+'''空'''+'))'
Exec(@CreateSQL)

读书人网 >SQL Server

热点推荐