sqlserver数据库最大Id冲突问题解决方法之一
时间:2024-01-28 01:48:06
CREATE TABLE [dbo].[TbGuidTable](
[TableName] [varchar](50) NOT NULL,
[KeyName] [varchar](20) NOT NULL,
[KeyValue] [varchar](100) NOT NULL
) ON [PRIMARY]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'PCreateGuid') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure PCreateGuid
GO
------------------------------------
--用途:增加一条记录 个人信息
--项目名称:
--说明:
--时间:2011-7-4 15:34:12,2011-08-15
------------------------------------
CREATE PROCEDURE PCreateGuid
@tableName varchar(50),
@keyname varchar(100),
@guid varchar(100) out
as
if not exists(select * from TbGuidTable where tablename=@tableName and keyname=@keyname)
insert into TbGuidTable (tablename,keyname,keyvalue) values(@tableName,@keyname,10000)
update TbGuidTable set keyvalue=keyvalue+1 where tablename=@tableName and keyname=@keyname
select @guid=cast(keyvalue as varchar) from TbGuidTable where tablename=@tableName and keyname=@keyname
Go
---*****---
declare @tableName varchar(50)
declare @keyname varchar(100)
declare @guid varchar(100)
set @tableName='tb1'
set @keyname='def'
execute PCreateGuid @tableName,@keyname,@guid out
print @guid
标签:数据库,最大Id
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
随Linux开机自动启动mysql
2009-12-29 10:14:00
python ddt实现数据驱动
2021-11-11 02:37:08
python读写excel数据--pandas详解
2022-08-07 03:34:13
![](https://img.aspxhome.com/file/2023/6/131546_0s.png)
Python解决两个整数相除只得到整数部分的实例
2021-12-29 23:29:21
Python聚类算法之基本K均值实例详解
2023-07-14 12:49:08
![](https://img.aspxhome.com/file/2023/8/120608_0s.png)
TensorFlow 模型载入方法汇总(小结)
2022-11-09 00:05:42
![](https://img.aspxhome.com/file/2023/2/86462_0s.png)
jQuery入门之–属性(一)
2009-07-12 15:29:00
python实现趣味图片字符化
2022-01-22 15:29:35
![](https://img.aspxhome.com/file/2023/1/124371_0s.jpg)
python和websocket构建实时日志跟踪器的步骤
2023-08-11 08:28:20
![](https://img.aspxhome.com/file/2023/7/115697_0s.gif)
python3连接mysql获取ansible动态inventory脚本
2024-01-19 23:13:54
python中numpy基础学习及进行数组和矢量计算
2023-01-22 16:32:04
![](https://img.aspxhome.com/file/2023/8/131248_0s.png)
python3.6实现学生信息管理系统
2021-02-09 20:54:48
如何计算ASP页面的加载时间/载入时间?
2009-11-25 20:10:00
python 实现分页显示从es中获取的数据方法
2023-04-21 07:13:18
Golang三个编译基本命令的使用小结
2023-08-28 05:08:03
![](https://img.aspxhome.com/file/2023/1/101691_0s.png)
服务端XMLHTTP(ServerXMLHTTP in ASP)基本应用(上)
2008-11-11 12:49:00
![](https://img.aspxhome.com/file/UploadPic/200811/11/63u9_google-92s.png)
linux环境下安装python虚拟环境及注意事项
2023-12-09 08:02:47
利用python求积分的实例
2023-07-08 15:44:23
python判断完全平方数的方法
2023-07-12 06:43:13
在mac下查找python包存放路径site-packages的实现方法
2023-06-12 21:12:36