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

MSSQL
SQL Server 2005查看文件及文件组的语句
用最简单的步骤备份SQL数据库的文件到本地
在SQL Server数据库中拆分字符串函数
SQL Server数据库维度表和事实表概述
Microsoft SQL Server数据库日志截断
SQL Server 2000 SP4与数据链接池问题
SQL Server游标使用实例
SQL Server 2008:传递表值参数
微软SQL Server 2008令商业智能平民化
将SQL2000数据库升级到SQL2005
在SQL Server2005中进行错误捕捉
动态SQL语句的编程
SQL Server 2008升级报表服务器数据库
在SAN上创建SQL Server群集
SQL查询中的转义序列不对的解决办法
SQL2005一个不起眼但很实用的函数
管理SQL Server数据库和应用元数据
选择SQL Server恢复模型确保正确备份
查看SQL执行计划常用方法
SQL2008增强的集成开发环境

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 204 ::
收藏到网摘: 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