如何用sql语句修改数据表中字段,实现identity(100,1)
添加时间: 2006-4-20 7:37:03 作者: SQL Server教程 阅读次数:132 来源: http://www.d9soft.com
create table common_info(
name varchar(10),
value int)
insert into common_info values('msg_count', 100)
你的sql应该这么写(用存储过程):
create proc p_ins_alm_msg
@msg_count int out
as
select @msg_count = value from common_info where name = 'msg_count'
update common_info set value = @msg_count+ 1 where name = 'msg_count' and value =
@msg_count
if @@rowcount = 0
return -1000
insert into table1 (field0)
values(@msg_count)
return 0
go
name varchar(10),
value int)
insert into common_info values('msg_count', 100)
你的sql应该这么写(用存储过程):
create proc p_ins_alm_msg
@msg_count int out
as
select @msg_count = value from common_info where name = 'msg_count'
update common_info set value = @msg_count+ 1 where name = 'msg_count' and value =
@msg_count
if @@rowcount = 0
return -1000
insert into table1 (field0)
values(@msg_count)
return 0
go
上下文章:
上一篇文章: SQL Server 7.0与以前的版本相比,安全模式中最重要的 下一篇文章: Web环境下MS SQL Server中数据的磁带备份与恢复
相关文章:

