日期:2014-05-17  浏览次数:20423 次

关于动态建表的一个问题
  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)