当前位置: 代码迷 >> Sql Server >> 表加一字段,默认值取表中另一字段的值如何写
  详细解决方案

表加一字段,默认值取表中另一字段的值如何写

热度:34   发布时间:2016-04-27 13:12:14.0
表加一字段,默认值取表中另一字段的值怎么写
各位大神,如题,在表中加一字段,字段的值同表中另一字段的值。
怎么写呢 这个

------解决方案--------------------
SQL code
--创建一个表create table tablename (id int)--插入两条数据insert into tablename select 1 union all select 7--添加一个列alter table tablename add nid as ([id])--查看表中数据select * from tablename/*id          nid----------- -----------1           17           7*/
  相关解决方案