表中结构是这样:Id,Sorce
1,1
2,2
3,2
.
.
.
新增一列,要求新增列Sorce的值 是当前表中最大的Sorce值加一
1,1
2,2
3,2
.
.
.
新增一列,要求新增列Sorce的值 是当前表中最大的Sorce值加一
解决方案 »
- sqlserver2000和2005可以装在一台机器上吗?
- 获取“视图定义”的SQL语句出错,主要是“视图定义”的SQL的长度超过4000,难道“视图定义”长度不能超过4000吗?
- 无从下手,请高手支招。
- left join + group by 求sum
- 用SQL对ms-sqlserver数据库里的address字段作替换操作?(在先等急)
- 求高手解答一个问题
- 关于动态游标变量的定义问题,请大虾们指教.....
- 请大家帮忙看看,为什么我查询会选出错误的记录...
- 请问有没有转化字符串为数字的函数!!!!!!!!!
- 在线等待 如何在sql中一次实现
- 附代码。求解。哪里出问题了?出错了但执行不停止
- 求《SQL Server 2005数据库系统开发案例精选》的光盘
如果是新增一条记录
insert into tablename values ((select max(id) from @tabel)+1,(select max(sorce) from tabelname)+1 )
'"+select max(SortIndex) from ProductCategory where ParentId is null)+1+"','"+UserID+"')";
可是我这样写不对啊
'select max(SortIndex) from ProductCategory where ParentId is null)+1', '"+UserID+"')";这样写也不对,
alter table tb add[max_sorce] int
update tb set max_sorce=((select max(sorce) from tb)+1)