在一张表中,有一字段类型为int,取值0,1,2。我想让0代表高中,1代表大学,2代表研究生。这种代表的意义能否在字段定义时就约定好么?

解决方案 »

  1.   

    用int型好呢?还是直接用nvarchar呢?若用int型,该怎么在程序中约定?
      

  2.   

    我想SQL Server应该有这样的功能,就是数据库中存储的是数字,查找结果是字符串。这应该在建表时就应该实现,不需编码。请教会设置的人,谢谢。
      

  3.   

    declare @tb table (id int,name int)
    insert into @tb select 1,0
    insert into @tb select 2,1
    insert into @tb select 3,2select id,
    case when name=0 then '高中'
    when name=1 then '本科'
    when name=2 then '研究生' end as name 
    from @tb这样?实在没看懂你的意思