用RULE
新建一个RULE
把它跟这一列邦定

解决方案 »

  1.   

    用RULE
    新建一个RULE,其default为70,然后再加一check约束就可以了
      

  2.   

    我是建了一个DEFAULT,值为70,再建一个RULE,设定值在60~100,但是我不知怎么写规则的TEXT
      

  3.   

    This example creates a rule that performs the same function as the CHECK constraint example in the preceding topic. The CHECK constraint is the preferred method to use in Microsoft® SQL Server™ 2000.CREATE RULE id_chk AS @id BETWEEN 0 and 10000
    GO
    CREATE TABLE cust_sample
       (
       cust_id            int
       PRIMARY KEY,
       cust_name         char(50),
       cust_address         char(50),
       cust_credit_limit   money,
       )
    GO
    sp_bindrule id_chk, 'cust_sample.cust_id'
    GO
      

  4.   

    create rule MyRange              --建立规则
    as 
      (@range>60 and @range<100)create default MyDefault as 70    --建立默认值exec sp_addtype MyInt,'int'          --建立自己的数据类型exec sp_bindrule MyRange_rule,MyInt  --绑定规则exec sp_bindefault MyDefault,MyInt   --绑定默认值