Showing posts with label unique. Show all posts
Showing posts with label unique. Show all posts

Wednesday, March 28, 2012

Multi-Table IDENTITY

Is there a way to associate IDENTITY columns from two different tables, so that new records created in either table will have mutually unique values?

That is, a new record in table A will be given value 1, and then a new record created in table B will be given value 2 (because value 1 was already used by the IDENTITY column in table A). Can this be done?

No, identity fields are only unique within the table.

Monday, March 19, 2012

Multiple Unique Keys

Hello everyone. I attempting to construct a table where a single row can be
individually identified by a unique value that is composed of more than one
column. How can define multiple unique keys for a table? Thanks to everyone
for being there to help.
Simply include all the appropriate columns in the PK definition:
CREATE TABLE [dbo].[Demo] (
[a] [int] NOT NULL ,
[b] [int] NOT NULL ,
[c] [int] NOT NULL ,
CONSTRAINT [PK_Demo] PRIMARY KEY CLUSTERED
(
[a],
[b],
[c]
)
)
Roy Harvey
Beacon Falls, CT
On Wed, 29 Nov 2006 07:46:01 -0800, coenzyme
<coenzyme@.discussions.microsoft.com> wrote:

>Hello everyone. I attempting to construct a table where a single row can be
>individually identified by a unique value that is composed of more than one
>column. How can define multiple unique keys for a table? Thanks to everyone
>for being there to help.
|||Thanks for responding Roy.
"Roy Harvey" wrote:

> Simply include all the appropriate columns in the PK definition:
> CREATE TABLE [dbo].[Demo] (
> [a] [int] NOT NULL ,
> [b] [int] NOT NULL ,
> [c] [int] NOT NULL ,
> CONSTRAINT [PK_Demo] PRIMARY KEY CLUSTERED
> (
> [a],
> [b],
> [c]
> )
> )
> Roy Harvey
> Beacon Falls, CT
> On Wed, 29 Nov 2006 07:46:01 -0800, coenzyme
> <coenzyme@.discussions.microsoft.com> wrote:
>

Multiple Unique Keys

Hello everyone. I attempting to construct a table where a single row can be
individually identified by a unique value that is composed of more than one
column. How can define multiple unique keys for a table? Thanks to everyone
for being there to help.Simply include all the appropriate columns in the PK definition:
CREATE TABLE [dbo].[Demo] (
[a] [int] NOT NULL ,
[b] [int] NOT NULL ,
[c] [int] NOT NULL ,
CONSTRAINT [PK_Demo] PRIMARY KEY CLUSTERED
(
[a],
[b],
[c]
)
)
Roy Harvey
Beacon Falls, CT
On Wed, 29 Nov 2006 07:46:01 -0800, coenzyme
<coenzyme@.discussions.microsoft.com> wrote:

>Hello everyone. I attempting to construct a table where a single row can be
>individually identified by a unique value that is composed of more than one
>column. How can define multiple unique keys for a table? Thanks to everyone
>for being there to help.|||Thanks for responding Roy.
"Roy Harvey" wrote:

> Simply include all the appropriate columns in the PK definition:
> CREATE TABLE [dbo].[Demo] (
> [a] [int] NOT NULL ,
> [b] [int] NOT NULL ,
> [c] [int] NOT NULL ,
> CONSTRAINT [PK_Demo] PRIMARY KEY CLUSTERED
> (
> [a],
> [b],
> [c]
> )
> )
> Roy Harvey
> Beacon Falls, CT
> On Wed, 29 Nov 2006 07:46:01 -0800, coenzyme
> <coenzyme@.discussions.microsoft.com> wrote:
>
>