生成唯一 ID 与多个表共享 SQL 2008 [英] Generate unique ID to share with multiple tables SQL 2008

查看:33
本文介绍了生成唯一 ID 与多个表共享 SQL 2008的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SQL 2008 服务器中有几个表,我需要为其生成唯一 ID.我查看了身份"列,但 ID 确实需要唯一并在所有表之间共享.

I have a couple of tables in a SQL 2008 server that I need to generate unique ID's for. I have looked at the "identity" column but the ID's really need to be unique and shared between all the tables.

因此,如果我说 (5) 五个资产基础结构"风格的表,并且我想在它们之间使用唯一 ID 作为组合组运行,我需要某种生成器来查看所有 (5) 五个表并发出下一个 ID,该 ID 在这 (5) 个五个故事中的任何一个中都没有重复.

So if I have say (5) five tables of the flavour "asset infrastructure" and I want to run with a unique ID between them as a combined group, I need some sort of generator that looks at all (5) five tables and issues the next ID which is not duplicated in any of those (5) five tales.

我知道这可以通过某种存储过程来完成,但我不确定如何去做.有什么想法吗?

I know this could be done with some sort of stored procedure but I'm not sure how to go about it. Any ideas?

推荐答案

为什么不使用 GUID?

Why not use a GUID?

这篇关于生成唯一 ID 与多个表共享 SQL 2008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆