在单个表中创建两个标识列的问题 [英] Problem in creating two identity columns in a single table

查看:20
本文介绍了在单个表中创建两个标识列的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在单个表中创建两个标识列时遇到问题.这是我的工作的一部分......他们不惜一切代价需要在一个表中的两个标识列.有没有办法做到这一点.

I am having a problem in creating two identity columns in a single table. This is my part of job... They need two identity columns in a single table at any cost. Is there any way to do this.

请提供用于在单个表中一次或稍后创建两个标识列的任何语法.

Please provide any syntax for creating two identity columns in a single table at a time or later also.

提前致谢,夏什拉

推荐答案

在 SQL Server 中,你可以有一个计算列,它只保存与标识(或任何其他)列相同的值:

In SQL Server, you can have a computed column which just holds the same value as an identity (or any other) column:

CREATE TABLE [dbo].[test](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [idCopy]  AS ([id]),
    [whatever] [nvarchar](max) NOT NULL
)

这篇关于在单个表中创建两个标识列的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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