当前位置: 首页 > 图文教程 > 数据库 > MSSQL > 如何用sql语句修改数据表中字段,实现identity(100,1)

MSSQL
讲解数据库调优与程序员相关的几个方面
揭开微软SQL Server 2008的神秘面纱
SQL Server 2008:表值参数的创建和使用
在SQL Server 2008中运用表值参数(TVP)
解读微软SQL Server 2008空间数据
微软SQL Server 2008 的新压缩特性
带你深入了解SQL Server 2008独到之处
如何使用SQL Server 2008升级顾问
详解SQL Server 2008中的联机事务处理
解读SQL Server 2008的新语句MERGE
使用SQL Server 2008进行服务器合并
SQL Server 2008:开辟崭新数据平台
微软数据平台开发与SQL Server 2008
微软SQL Server 2008之行值构造器
SQL Server 2008 数据加载创世界记录
浅析SQL2008的Change Data Capture功能
SQL Server大数据量统计系统的经验总结
详解Windows Server 2008中的NAP
SqlServer2005对现有数据进行分区具体步骤
无数据库日志文件恢复数据库方法两则(二)

MSSQL 中的 如何用sql语句修改数据表中字段,实现identity(100,1)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 206 ::
收藏到网摘: n/a

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